N
Nathan Diederich
Hi,
I'm currently writing a multithreaded app where one of the threads is
waiting on information from the others. This is not the main UI thread,
though the UI thread is the one that can signal this one to kill itself.
ThreadEntryPoint()
{
//setup
while (_continue)
{
_autoEvent.WaitOne();
//
//doing other stuff
//
}
//cleanup
}
My question is this...to kill this thread I have a method that changes
the bool _continue to false, but the while loop won't exit until
_autoEvent is signalled to release the thread. What would happen if I
have the method changing the bool also do _autoEvent.Close()?
- Would it hang because there is a WaitOne()?
- Would the WaitOne return true or false or throw an exception?
I'm hoping you can tell me that it returns a false so I can tell the
rest of the loop not to execute so I can exit the thread quickly.
Thanks,
Nathan
I'm currently writing a multithreaded app where one of the threads is
waiting on information from the others. This is not the main UI thread,
though the UI thread is the one that can signal this one to kill itself.
ThreadEntryPoint()
{
//setup
while (_continue)
{
_autoEvent.WaitOne();
//
//doing other stuff
//
}
//cleanup
}
My question is this...to kill this thread I have a method that changes
the bool _continue to false, but the while loop won't exit until
_autoEvent is signalled to release the thread. What would happen if I
have the method changing the bool also do _autoEvent.Close()?
- Would it hang because there is a WaitOne()?
- Would the WaitOne return true or false or throw an exception?
I'm hoping you can tell me that it returns a false so I can tell the
rest of the loop not to execute so I can exit the thread quickly.
Thanks,
Nathan