ManualResetEvent
ManualResetEvent mre=new ManualResetEvent(false);
//......
var signalled=mre.WaitOne(TimeSpan.FromSeconds(8));
if(signalled)
{
//cancel the event
}
elsewhere (before the 8 seconds is up):
mre.Set(); //unfreezes paused Thread and causes signalled==true
and allow the unblocked thread to terminate gracefully.
Thread.Abort
is evil and should be avoided.
Once mre.Set(), mre.WaitOne(TimeSpan.FromSeconds(8)); mre always return a signal, you need to "unset" the ManualResetEvent by
No comments:
Post a Comment