multithreading - Is there a way to cancel "AsyncWaitHandle.WaitOne()"? -


thanks to help advance

I want to cancel AsyncWaitHandle.WaitOne () at some point in my code (which means that I do not want to block anymore), but let me do this Can not find the way. Probably, this is a logical problem of my program, but as soon as the signal is given to exit, I can not think of any other way to exit the loop. The following is the code that has the problem:

  s.Bind (the end page); S.Listen (15); While (true) {thrd = s.BeginAccept (new Accept_Callback), s); Thrd.AsyncWaitHandle.WaitOne (); // it still blocks when the next statement becomde "true" (_syncEvents.ExitThreadEvent.WaitOne (0, wrong)) // I want to break out of the loop at this point, it only thrd coming to the next call when .syncWaitHandle. Close (); S.Close (); break;     

Comments