OpenDevice ( ), , . :
OpenDevice();
WaitForEvent = EventEnum.DeviceOpened;
, DeviceOpenedEvent , , WaitForEvent - EventEnum.None:
if (WaitForEvent == EventEnum.DeviceOpened)
TestAutoResetEvent.Set();
, , , . , , :
protected AutoResetEvent deviceOpenedEvent = new AutoResetEvent(false);
protected AutoResetEvent deviceLockedEvent = new AutoResetEvent(false);
bool TestDevice() {
OpenDevice();
deviceOpenedEvent.WaitOne();
LockDevice();
deviceLockedEvent.WaitOne();
}
void DeviceOpenedEvent() {
deviceOpenedEvent.Set();
}
, OpenDevice: deviceOpened.Set(), . OpenDevice, auto reset TestDevice, .