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?
[Code]
void ThreadMethod1()
{
while (true)
{
Thread.Sleep(1000);
if (stop)
{
// break;
}
else
{
// do something
}
}
}
[/Code]
thanks in advance,
George
George GeorgePosted Jun 3, 2008, 8:20 AM
Thanks Jan,
Using Event other than usnig sleep could have better performance (I mean less performance impact to other part of application considering the resources like CPU time consumed by Event v.s. Sleep)?
regards,
George
Jan MontanoPosted Jun 3, 2008, 3:31 AM