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

Jan MontanoRank #1,295 · 1.3K reputationPosted Jun 2, 2008, 11:31 PM EDT
George GeorgeRank #1,736 · 870 reputationPosted Jun 3, 2008, 4:20 AM EDT
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