About AutoResetEvent
-
bool WaitOne() is true if the current instance receives a signal. It will never be false since it won't return if it is unsignaled.
-
bool WaitOne() is true if the current instance receives a signal. It will never be false since it won't return if it is unsignaled.
Thank you for your reply. I have also checked a lot these days, and come to the same conclusion Would tell me if there are some difference between using AutoResetEvent' WaitOne/Set in forground-thread (started by Thread.Start() )and background thread(started by BeginInvoke()). I have a problem that WaitOne() returned before it is Set() at another thread. As it happens not so frequently, I still don't know the reason. I my app, except for the main thread, all threads are started by BeginInvoke. Thnak you! -- modified at 2:07 Thursday 30th March, 2006
-
Thank you for your reply. I have also checked a lot these days, and come to the same conclusion Would tell me if there are some difference between using AutoResetEvent' WaitOne/Set in forground-thread (started by Thread.Start() )and background thread(started by BeginInvoke()). I have a problem that WaitOne() returned before it is Set() at another thread. As it happens not so frequently, I still don't know the reason. I my app, except for the main thread, all threads are started by BeginInvoke. Thnak you! -- modified at 2:07 Thursday 30th March, 2006
Bob_Sun wrote:
Would tell me if there are some difference between using AutoResetEvent' WaitOne/Set in forground-thread (started by Thread.Start() )and background thread(started by BeginInvoke()).
I believe there is no difference. Anyway, you need to initialize the AutoResetEvent as unsignaled before using it: AutoResetEvent are = new AutoResetEvent(false); It also needs to be in the same scope as the thread waiting for the signal.