Programming Reference:WaitableEvent Class

From BCI2000 Wiki
Jump to navigation Jump to search




The WaitableEvent class provides a mechanism to synchronize threads by waiting for another thread to signal the WaitableEvent. The underlying functionality corresponds to a manual-reset event in Windows.



Events are created in non-signaled state.


Releases all resources allocated for the event object.

bool Set()

Sets the event to signaled state. When one or more threads are blocked waiting for the event, they are released in random order. As long as the event is in signaled state, threads calling its Wait() function will not be blocked. Returns true when successful, false otherwise.

bool Reset()

Resets the event to non-signaled state. Call Reset() immediately after Wait() to emulate the behavior of a Windows auto-reset event. Returns true when successful, false otherwise.

bool Wait([TimeInterval timeout])

Waits for the event to become signaled. Does nothing when the event is currently in signaled state. When a timeout is specified, waits no longer than the specified amount of time. Returns true when the event is signaled, and false otherwise (error or timeout occurred).

See also

Programming Reference:Thread Class