Click here to Skip to main content
15,893,588 members
Home / Discussions / C#
   

C#

 
QuestionIntercepting and blocking Webpages Pin
CJayMeister11-Jul-06 2:41
CJayMeister11-Jul-06 2:41 
AnswerRe: Intercepting and blocking Webpages Pin
J4amieC11-Jul-06 2:54
J4amieC11-Jul-06 2:54 
GeneralRe: Intercepting and blocking Webpages Pin
CJayMeister11-Jul-06 3:09
CJayMeister11-Jul-06 3:09 
GeneralRe: Intercepting and blocking Webpages Pin
Eran Aharonovich11-Jul-06 4:44
Eran Aharonovich11-Jul-06 4:44 
AnswerRe: Intercepting and blocking Webpages Pin
led mike11-Jul-06 5:22
led mike11-Jul-06 5:22 
AnswerCreate a proxy Pin
Ennis Ray Lynch, Jr.11-Jul-06 9:51
Ennis Ray Lynch, Jr.11-Jul-06 9:51 
AnswerProxy server Pin
Daniel Turini11-Jul-06 9:51
Daniel Turini11-Jul-06 9:51 
Questionlock() and Thread.Interrupt() Pin
Jon Hulatt11-Jul-06 0:37
Jon Hulatt11-Jul-06 0:37 
Hi,

My worker thread looks a bit like this:-

private void CacheThread()
    {
        while (true)
        {
           lock (myobject)
           {
               myobject.DoSomeWork();

           }

            try
            {
                System.Threading.Thread.Sleep(100);
            }
            catch (ThreadInterruptedException)
            {
            }
        }
    }


The thread spends the majority of it's time sleeping. Another thread uses Thread.Interrupt() to wake it up when it is necessary to DoSomeWork().

The majority of the time, it's fine - the thread is in the sleep and is interrupted.

But sometimes, I get an unhandled ThreadInterruptedException on the lock() line.

I presume that internally, CLR is using a win32 WaitFor... function, and is interupted. But I don't want my thread to wake up until it can claim the lock.

Is there an alternative? I want to wake the thread from my sleep, but not from a lock()-induced sleep.

Thanks

Jon

using System.Beer;

AnswerRe: lock() and Thread.Interrupt() [modified] Pin
Guffa11-Jul-06 1:01
Guffa11-Jul-06 1:01 
GeneralRe: lock() and Thread.Interrupt() Pin
Jon Hulatt11-Jul-06 3:11
Jon Hulatt11-Jul-06 3:11 
AnswerRe: lock() and Thread.Interrupt() Pin
Aaron Dilliard11-Jul-06 4:02
Aaron Dilliard11-Jul-06 4:02 
AnswerRe: lock() and Thread.Interrupt() Pin
Judah Gabriel Himango11-Jul-06 4:48
sponsorJudah Gabriel Himango11-Jul-06 4:48 
AnswerRe: lock() and Thread.Interrupt() Pin
led mike11-Jul-06 5:12
led mike11-Jul-06 5:12 
QuestionQuestion about subtract Time in c# ( IDE 2005 ) Pin
Yanshof11-Jul-06 0:10
Yanshof11-Jul-06 0:10 
AnswerRe: Question about subtract Time in c# ( IDE 2005 ) Pin
Shajeel11-Jul-06 0:28
Shajeel11-Jul-06 0:28 
GeneralIts not working .Someone can help please ? Pin
Yanshof11-Jul-06 1:06
Yanshof11-Jul-06 1:06 
GeneralRe: Its not working .Someone can help please ? Pin
Christian Graus11-Jul-06 1:16
protectorChristian Graus11-Jul-06 1:16 
GeneralRe: Its not working .Someone can help please ? Pin
Sebastian Schneider11-Jul-06 1:27
Sebastian Schneider11-Jul-06 1:27 
GeneralRe: Its not working .Someone can help please ? Pin
Yanshof11-Jul-06 1:35
Yanshof11-Jul-06 1:35 
GeneralRe: Its not working .Someone can help please ? [modified] Pin
Shajeel11-Jul-06 1:42
Shajeel11-Jul-06 1:42 
GeneralRe: Its not working .Someone can help please ? Pin
J4amieC11-Jul-06 1:59
J4amieC11-Jul-06 1:59 
QuestionMono Pin
mehrdadc4811-Jul-06 0:08
mehrdadc4811-Jul-06 0:08 
AnswerRe: Mono Pin
Sebastian Schneider11-Jul-06 1:15
Sebastian Schneider11-Jul-06 1:15 
AnswerRe: Mono Pin
User 665811-Jul-06 4:37
User 665811-Jul-06 4:37 
GeneralRe: Mono Pin
User 171649211-Jul-06 5:30
professionalUser 171649211-Jul-06 5:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.