|C#||Visual Basic||Visual C++|
Public Shared Function WaitForEvent ( _ sessionHandle As MonoUsbSessionHandle, _ ByRef timeval As UnixNativeTimeval _ ) As Integer
- 0 after a transfer completes or another thread stops event handling.
- 1 if the timeout expired.
This function will block until any of the following conditions are met: The timeout expires.A transfer completes.A thread releases the event handling lock through libusb_unlock_events.
Condition 1 is obvious. Condition 2 unblocks your thread after the callback for the transfer has completed. Condition 3 is important because it means that the thread that was previously handling events is no longer doing so, so if any events are to complete, another thread needs to step up and start event handling.
This function releases the event waiters lock before putting your thread to sleep, and reacquires the lock as it is being woken up.