Show / Hide Table of Contents

Class AsyncTrigger

Represents asynchronous trigger which allows to resume suspended callers based on registered conditions.

Inheritance
Object
QueuedSynchronizer
AsyncTrigger
Implements
IAsyncEvent
ISynchronizer
IDisposable
Inherited Members
QueuedSynchronizer.ISynchronizer.HasWaiters
QueuedSynchronizer.CancelSuspendedCallers(CancellationToken)
QueuedSynchronizer.Dispose(Boolean)
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public class AsyncTrigger : QueuedSynchronizer, IAsyncEvent, ISynchronizer, IDisposable

Methods

| Improve this Doc View Source

Signal()

Signals to all suspended callers that do not rely on state.

Declaration
public void Signal()
Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

| Improve this Doc View Source

Signal<TState>(TState)

Signals to all suspended callers about the new state.

Declaration
public void Signal<TState>(TState state)

    where TState : class
Parameters
Type Name Description
TState state

The new state of the trigger.

Type Parameters
Name Description
TState

The type of the state maintained externally.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

| Improve this Doc View Source

Signal<TState>(TState, Action<TState>)

Signals to all suspended callers about the new state.

Declaration
public void Signal<TState>(TState state, Action<TState> mutator)

    where TState : class
Parameters
Type Name Description
TState state

The state to be modified.

Action<TState> mutator

State mutation.

Type Parameters
Name Description
TState

The type of the state maintained externally.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

| Improve this Doc View Source

Signal<TState, TArgs>(TState, Action<TState, TArgs>, TArgs)

Signals to all suspended callers about the new state.

Declaration
public void Signal<TState, TArgs>(TState state, Action<TState, TArgs> mutator, TArgs args)

    where TState : class
Parameters
Type Name Description
TState state

The state to be modified.

Action<TState, TArgs> mutator

State mutation.

TArgs args

The arguments to be passed to the mutator.

Type Parameters
Name Description
TState

The type of the state maintained externally.

TArgs

The type of the arguments of state mutator.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

| Improve this Doc View Source

SignalAndWaitAsync(CancellationToken)

Signals to all suspended callers and waits for the signal.

Declaration
public Task SignalAndWaitAsync(CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task

The task representing asynchronous execution of this method.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

SignalAndWaitAsync(TimeSpan, CancellationToken)

Signals to all suspended callers and waits for the signal.

Declaration
public Task<bool> SignalAndWaitAsync(TimeSpan timeout, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
TimeSpan timeout

The time to wait for the signal.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task<Boolean>

true if event is triggered in timely manner; false if timeout occurred.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

SignalAndWaitAsync<TState>(TState, Action<TState>, Predicate<TState>, CancellationToken)

Signals to all suspended callers and waits for the event that meets to the specified condition atomically.

Declaration
public Task SignalAndWaitAsync<TState>(TState state, Action<TState> mutator, Predicate<TState> condition, CancellationToken token = default(CancellationToken))

    where TState : class
Parameters
Type Name Description
TState state

The state to be inspected by predicate.

Action<TState> mutator

State mutation action.

Predicate<TState> condition

The condition to wait for.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task

The task representing asynchronous execution of this method.

Type Parameters
Name Description
TState

The type of the state to be inspected.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

SignalAndWaitAsync<TState>(TState, Action<TState>, Predicate<TState>, TimeSpan, CancellationToken)

Signals to all suspended callers and waits for the event that meets to the specified condition atomically.

Declaration
public Task<bool> SignalAndWaitAsync<TState>(TState state, Action<TState> mutator, Predicate<TState> condition, TimeSpan timeout, CancellationToken token = default(CancellationToken))

    where TState : class
Parameters
Type Name Description
TState state

The state to be inspected by predicate.

Action<TState> mutator

State mutation action.

Predicate<TState> condition

The condition to wait for.

TimeSpan timeout

The time to wait for the signal.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task<Boolean>

true if event is triggered in timely manner; false if timeout occurred.

Type Parameters
Name Description
TState

The type of the state to be inspected.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

SignalAndWaitAsync<TState>(TState, Predicate<TState>, CancellationToken)

Signals to all suspended callers and waits for the event that meets to the specified condition atomically.

Declaration
public Task SignalAndWaitAsync<TState>(TState state, Predicate<TState> condition, CancellationToken token = default(CancellationToken))

    where TState : class
Parameters
Type Name Description
TState state

The state to be inspected by predicate.

Predicate<TState> condition

The condition to wait for.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task

The task representing asynchronous execution of this method.

Type Parameters
Name Description
TState

The type of the state to be inspected.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

SignalAndWaitAsync<TState>(TState, Predicate<TState>, TimeSpan, CancellationToken)

Signals to all suspended callers and waits for the event that meets to the specified condition atomically.

Declaration
public Task<bool> SignalAndWaitAsync<TState>(TState state, Predicate<TState> condition, TimeSpan timeout, CancellationToken token = default(CancellationToken))

    where TState : class
Parameters
Type Name Description
TState state

The state to be inspected by predicate.

Predicate<TState> condition

The condition to wait for.

TimeSpan timeout

The time to wait for the signal.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task<Boolean>

true if event is triggered in timely manner; false if timeout occurred.

Type Parameters
Name Description
TState

The type of the state to be inspected.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

SignalAndWaitAsync<TState, TArgs>(TState, Action<TState, TArgs>, TArgs, Predicate<TState>, CancellationToken)

Signals to all suspended callers and waits for the event that meets to the specified condition atomically.

Declaration
public Task SignalAndWaitAsync<TState, TArgs>(TState state, Action<TState, TArgs> mutator, TArgs args, Predicate<TState> condition, CancellationToken token = default(CancellationToken))

    where TState : class
Parameters
Type Name Description
TState state

The state to be inspected by predicate.

Action<TState, TArgs> mutator

State mutation action.

TArgs args

The arguments to be passed to the action.

Predicate<TState> condition

The condition to wait for.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task

The task representing asynchronous execution of this method.

Type Parameters
Name Description
TState

The type of the state to be inspected.

TArgs

The type of the arguments of mutation action.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

SignalAndWaitAsync<TState, TArgs>(TState, Action<TState, TArgs>, TArgs, Predicate<TState>, TimeSpan, CancellationToken)

Signals to all suspended callers and waits for the event that meets to the specified condition atomically.

Declaration
public Task<bool> SignalAndWaitAsync<TState, TArgs>(TState state, Action<TState, TArgs> mutator, TArgs args, Predicate<TState> condition, TimeSpan timeout, CancellationToken token = default(CancellationToken))

    where TState : class
Parameters
Type Name Description
TState state

The state to be inspected by predicate.

Action<TState, TArgs> mutator

State mutation action.

TArgs args

The arguments to be passed to the action.

Predicate<TState> condition

The condition to wait for.

TimeSpan timeout

The time to wait for the signal.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task<Boolean>

true if event is triggered in timely manner; false if timeout occurred.

Type Parameters
Name Description
TState

The type of the state to be inspected.

TArgs

The type of the arguments of mutation action.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

WaitAsync(TimeSpan, CancellationToken)

Suspends the caller and waits for the signal.

Declaration
public Task<bool> WaitAsync(TimeSpan timeout, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
TimeSpan timeout

The time to wait for the signal.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task<Boolean>

true if event is triggered in timely manner; false if timeout occurred.

Remarks

This method always suspends the caller.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

OperationCanceledException

The operation has been canceled.

See Also
Signal()
| Improve this Doc View Source

WaitAsync<TState>(TState, Predicate<TState>, CancellationToken)

Suspends the caller and waits for the event that meets to the specified condition.

Declaration
public Task WaitAsync<TState>(TState state, Predicate<TState> condition, CancellationToken token = default(CancellationToken))

    where TState : class
Parameters
Type Name Description
TState state

The state to be inspected by predicate.

Predicate<TState> condition

The condition to wait for.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task

true if event is triggered in timely manner; false if timeout occurred.

Type Parameters
Name Description
TState

The type of the state to be inspected.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

WaitAsync<TState>(TState, Predicate<TState>, TimeSpan, CancellationToken)

Suspends the caller and waits for the event that meets to the specified condition.

Declaration
public Task<bool> WaitAsync<TState>(TState state, Predicate<TState> condition, TimeSpan timeout, CancellationToken token = default(CancellationToken))

    where TState : class
Parameters
Type Name Description
TState state

The state to be inspected by predicate.

Predicate<TState> condition

The condition to wait for.

TimeSpan timeout

The time to wait for the signal.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task<Boolean>

true if event is triggered in timely manner; false if timeout occurred.

Type Parameters
Name Description
TState

The type of the state to be inspected.

Exceptions
Type Condition
ObjectDisposedException

This trigger has been disposed.

OperationCanceledException

The operation has been canceled.

Explicit Interface Implementations

| Improve this Doc View Source

IAsyncEvent.IsSet

Declaration
bool IAsyncEvent.IsSet { get; }
Returns
Type Description
Boolean
| Improve this Doc View Source

IAsyncEvent.Reset()

Declaration
bool IAsyncEvent.Reset()
Returns
Type Description
Boolean
| Improve this Doc View Source

IAsyncEvent.Signal()

Declaration
bool IAsyncEvent.Signal()
Returns
Type Description
Boolean

Implements

IAsyncEvent
ISynchronizer
System.IDisposable

Extension Methods

AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, CancellationToken)
AsyncEvent.WaitAsync(IAsyncEvent, TimeSpan)
AsyncEvent.WaitAsync(IAsyncEvent, CancellationToken)
AsyncEvent.WaitAsync(IAsyncEvent)
ObjectExtensions.GetUserData<T>(T)
ObjectExtensions.IsOneOf<T>(T, IEnumerable<T>)
ObjectExtensions.IsOneOf<T>(T, T[])
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, Func<T, TResult1>, Func<T, TResult2>, out TResult1, out TResult2)
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, ValueFunc<T, TResult1>, ValueFunc<T, TResult2>, out TResult1, out TResult2)
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, Func<T, TResult1>, Func<T, TResult2>)
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, ValueFunc<T, TResult1>, ValueFunc<T, TResult2>)
ObjectExtensions.As<T>(T)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
ExpressionBuilder.Const<T>(T)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX