Asynchronous Trigger
AsyncTrigger offers a simple synchronization for producer-consumer scenario:
- There is one or more suspended flows waiting for some event
- There is one or more signaling flows
The trigger offers the following methods for resuming and suspending the callers:
Signal
method allows to resume one or more suspended callersWaitAsync
suspends the caller until the call ofSignal
SignalAndWaitAsync
is an atomic combination ofSignal
andWaitAsync
methods
Signaling method behaves in two ways:
- Resume all suspended callers
- Resume the first waiting caller in the queue
AsyncTrigger
differs from AsyncAutoResetEvent synchronization primitive in the following aspects:
- There is no signaled state of the trigger. Therefore, any call to
WaitAsync
will be suspended and can be resumed only withSignal
method - The trigger can resume all suspended callers
SignalAndWaitAsync
allows to build a queue of signaling flows