I've noticed that AutoResetEvent completely freezes the message loop (sometimes) when in the middle of a WaitOne() call, effectively even blocking the signal message.
IE:
- (UI) New thread spawned
- (UI) Code calls WaitOne(); timeout: 10s
- (T2) Thread opens device, calls Set()
- (UI) WaitOne blocks message loop
- (UI) WaitOne timeout elapsed, code execution continues
- (UI) Main window receives signal and continues (but WaitOne failed)
Any ideas?
EDIT: added UI/T2's to specify threads. Also, I'm trying to turn a 3rd party library to synchronous. Opening devices involves an Open() call that in turn spawns an OpenOK or OpenFailed event, I'm trying to make a bool Open() call that returns true/false depending on which event was spawned.