Click here to Skip to main content
16,012,033 members
Home / Discussions / C#
   

C#

 
GeneralRe: Two basic questions about reflection Pin
George_George3-Jun-08 2:34
George_George3-Jun-08 2:34 
GeneralRe: Two basic questions about reflection Pin
PIEBALDconsult3-Jun-08 18:01
mvePIEBALDconsult3-Jun-08 18:01 
GeneralRe: Two basic questions about reflection Pin
George_George3-Jun-08 18:23
George_George3-Jun-08 18:23 
GeneralRe: Two basic questions about reflection Pin
PIEBALDconsult3-Jun-08 18:46
mvePIEBALDconsult3-Jun-08 18:46 
GeneralRe: Two basic questions about reflection Pin
George_George3-Jun-08 18:52
George_George3-Jun-08 18:52 
GeneralRe: Two basic questions about reflection Pin
PIEBALDconsult3-Jun-08 19:06
mvePIEBALDconsult3-Jun-08 19:06 
GeneralRe: Two basic questions about reflection Pin
George_George3-Jun-08 21:35
George_George3-Jun-08 21:35 
Questionhow to use event to re-write this code segment? Pin
George_George1-Jun-08 15:11
George_George1-Jun-08 15:11 
Hello everyone,


Here is my code segment for a thread, which will sleep one second, do some work and check if the stop status is set -- if set, then break the loop and stops the method.

My question is, whether it is possible to use event (e.g. ManualResetEvent) to implement similar logics?

void ThreadMethod1()
{
    while (true)
    {
        Thread.Sleep(1000);
        if (stop)
        {
            // break;
        }
        else
        {
            // do something
        }
    }
}



thanks in advance,
George
AnswerRe: how to use event to re-write this code segment? Pin
Christian Graus1-Jun-08 15:52
protectorChristian Graus1-Jun-08 15:52 
GeneralRe: how to use event to re-write this code segment? Pin
George_George1-Jun-08 16:24
George_George1-Jun-08 16:24 
GeneralRe: how to use event to re-write this code segment? Pin
Christian Graus1-Jun-08 16:39
protectorChristian Graus1-Jun-08 16:39 
GeneralRe: how to use event to re-write this code segment? Pin
George_George1-Jun-08 17:06
George_George1-Jun-08 17:06 
GeneralRe: how to use event to re-write this code segment? Pin
Christian Graus1-Jun-08 17:33
protectorChristian Graus1-Jun-08 17:33 
GeneralRe: how to use event to re-write this code segment? Pin
George_George1-Jun-08 17:44
George_George1-Jun-08 17:44 
GeneralRe: how to use event to re-write this code segment? Pin
Christian Graus1-Jun-08 17:57
protectorChristian Graus1-Jun-08 17:57 
GeneralRe: how to use event to re-write this code segment? Pin
George_George1-Jun-08 18:32
George_George1-Jun-08 18:32 
GeneralRe: how to use event to re-write this code segment? Pin
PIEBALDconsult2-Jun-08 6:22
mvePIEBALDconsult2-Jun-08 6:22 
GeneralRe: how to use event to re-write this code segment? Pin
N a v a n e e t h1-Jun-08 20:03
N a v a n e e t h1-Jun-08 20:03 
GeneralRe: how to use event to re-write this code segment? Pin
George_George2-Jun-08 1:08
George_George2-Jun-08 1:08 
GeneralRe: how to use event to re-write this code segment? Pin
N a v a n e e t h2-Jun-08 1:23
N a v a n e e t h2-Jun-08 1:23 
GeneralRe: how to use event to re-write this code segment? Pin
George_George2-Jun-08 1:48
George_George2-Jun-08 1:48 
GeneralRe: how to use event to re-write this code segment? Pin
N a v a n e e t h2-Jun-08 3:03
N a v a n e e t h2-Jun-08 3:03 
GeneralRe: how to use event to re-write this code segment? Pin
George_George3-Jun-08 1:56
George_George3-Jun-08 1:56 
GeneralRe: how to use event to re-write this code segment? Pin
N a v a n e e t h3-Jun-08 7:10
N a v a n e e t h3-Jun-08 7:10 
GeneralRe: how to use event to re-write this code segment? Pin
George_George3-Jun-08 15:30
George_George3-Jun-08 15: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.