Class AsyncExtensions
Extension methods for IAsyncOperation and related classes.
Inherited Members
Namespace: UnityFx.Async
Assembly: UnityFx.Async-netstandard2.0.dll
Syntax
public static class AsyncExtensions
Methods
| Improve this Doc View SourceAddCompletionCallback(IAsyncOperationCallbacks, Action)
Adds a completion callback to be executed after the operation has completed. If the operation is already completed
the callback is called synchronously.
Declaration
public static void AddCompletionCallback(this IAsyncOperationCallbacks op, Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperationCallbacks | op | The operation to schedule continuation for. |
| Action | callback | The callback to be executed when the operation has completed. |
Remarks
The callback is invoked on a thread that registered the continuation (if it has a SynchronizationContext attached).
Throwing an exception from the callback might cause unspecified behaviour.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ObjectDisposedException | Thrown is the operation has been disposed. |
AddCompletionCallback(IAsyncOperationCallbacks, Action, AsyncCallbackOptions)
Adds a completion callback to be executed after the operation has completed. If the operation is already completed
the callback is invoked on a context specified via options.
Declaration
public static void AddCompletionCallback(this IAsyncOperationCallbacks op, Action callback, AsyncCallbackOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperationCallbacks | op | The operation to schedule continuation for. |
| Action | callback | The callback to be executed when the operation has completed. |
| AsyncCallbackOptions | options | Identifier of a SynchronizationContext to schedule callback on. |
Remarks
The callback is invoked on a SynchronizationContext specified.
Throwing an exception from the callback might cause unspecified behaviour.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ObjectDisposedException | Thrown is the operation has been disposed. |
AddCompletionCallback(IAsyncOperationCallbacks, Action<IAsyncOperation>)
Adds a completion callback to be executed after the operation has completed. If the operation is already completed
the callback is called synchronously.
Declaration
public static void AddCompletionCallback(this IAsyncOperationCallbacks op, Action<IAsyncOperation> callback)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperationCallbacks | op | The operation to schedule continuation for. |
| System.Action<IAsyncOperation> | callback | The callback to be executed when the operation has completed. |
Remarks
The callback is invoked on a thread that registered the continuation (if it has a SynchronizationContext attached).
Throwing an exception from the callback might cause unspecified behaviour.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ObjectDisposedException | Thrown is the operation has been disposed. |
AddCompletionCallback(IAsyncOperationCallbacks, Action<IAsyncOperation>, AsyncCallbackOptions)
Adds a completion callback to be executed after the operation has completed. If the operation is already completed
the callback is invoked on a context specified via options.
Declaration
public static void AddCompletionCallback(this IAsyncOperationCallbacks op, Action<IAsyncOperation> callback, AsyncCallbackOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperationCallbacks | op | The operation to schedule continuation for. |
| System.Action<IAsyncOperation> | callback | The callback to be executed when the operation has completed. |
| AsyncCallbackOptions | options | Identifier of a SynchronizationContext to schedule callback on. |
Remarks
The callback is invoked on a SynchronizationContext specified.
Throwing an exception from the callback might cause unspecified behaviour.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ObjectDisposedException | Thrown is the operation has been disposed. |
AddCompletionCallback(IAsyncOperationCallbacks, IAsyncContinuation)
Adds a completion callback to be executed after the operation has completed. If the operation is already completed
the callback is called synchronously.
Declaration
public static void AddCompletionCallback(this IAsyncOperationCallbacks op, IAsyncContinuation callback)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperationCallbacks | op | The operation to schedule continuation for. |
| IAsyncContinuation | callback | The callback to be executed when the operation has completed. |
Remarks
The callback is invoked on a thread that registered the continuation (if it has a SynchronizationContext attached).
Throwing an exception from the callback might cause unspecified behaviour.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ObjectDisposedException | Thrown is the operation has been disposed. |
AddCompletionCallback(IAsyncOperationCallbacks, IAsyncContinuation, AsyncCallbackOptions)
Adds a completion callback to be executed after the operation has completed. If the operation is already completed
the callback is invoked on a context specified via options.
Declaration
public static void AddCompletionCallback(this IAsyncOperationCallbacks op, IAsyncContinuation callback, AsyncCallbackOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperationCallbacks | op | The operation to schedule continuation for. |
| IAsyncContinuation | callback | The callback to be executed when the operation has completed. |
| AsyncCallbackOptions | options | Identifier of a SynchronizationContext to schedule callback on. |
Remarks
The callback is invoked on a SynchronizationContext specified.
Throwing an exception from the callback might cause unspecified behaviour.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ObjectDisposedException | Thrown is the operation has been disposed. |
AddProgressCallback(IAsyncOperationCallbacks, Action<Single>)
Adds a callback to be executed when the operation progress has changed. If the operation is already completed
the callback is called synchronously.
Declaration
public static void AddProgressCallback(this IAsyncOperationCallbacks op, Action<float> callback)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperationCallbacks | op | The operation to schedule continuation for. |
| System.Action<Single> | callback | The callback to be executed when the operation progress has changed. |
Remarks
The callback is invoked on a thread that registered the callback (if it has a SynchronizationContext attached).
Throwing an exception from the callback might cause unspecified behaviour.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ObjectDisposedException | Thrown is the operation has been disposed. |
AddProgressCallback(IAsyncOperationCallbacks, Action<Single>, AsyncCallbackOptions)
Adds a callback to be executed when the operation progress has changed. If the operation is already completed
the callback is invoked on a context specified via options.
Declaration
public static void AddProgressCallback(this IAsyncOperationCallbacks op, Action<float> callback, AsyncCallbackOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperationCallbacks | op | The operation to schedule continuation for. |
| System.Action<Single> | callback | The callback to be executed when the operation progress has changed. |
| AsyncCallbackOptions | options | Identifier of a SynchronizationContext to schedule callback on. |
Remarks
The callback is invoked on a SynchronizationContext specified.
Throwing an exception from the callback might cause unspecified behaviour.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ObjectDisposedException | Thrown is the operation has been disposed. |
AddProgressCallback(IAsyncOperationCallbacks, IProgress<Single>)
Adds a callback to be executed when the operation progress has changed. If the operation is already completed
the callback is called synchronously.
Declaration
public static void AddProgressCallback(this IAsyncOperationCallbacks op, IProgress<float> callback)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperationCallbacks | op | The operation to schedule continuation for. |
| System.IProgress<Single> | callback | The callback to be executed when the operation progress has changed. |
Remarks
The callback is invoked on a thread that registered the callback (if it has a SynchronizationContext attached).
Throwing an exception from the callback might cause unspecified behaviour.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ObjectDisposedException | Thrown is the operation has been disposed. |
AddProgressCallback(IAsyncOperationCallbacks, IProgress<Single>, AsyncCallbackOptions)
Adds a callback to be executed when the operation progress has changed. If the operation is already completed
the callback is invoked on a context specified via options.
Declaration
public static void AddProgressCallback(this IAsyncOperationCallbacks op, IProgress<float> callback, AsyncCallbackOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperationCallbacks | op | The operation to schedule continuation for. |
| System.IProgress<Single> | callback | The callback to be executed when the operation progress has changed. |
| AsyncCallbackOptions | options | Identifier of a SynchronizationContext to schedule callback on. |
Remarks
The callback is invoked on a SynchronizationContext specified.
Throwing an exception from the callback might cause unspecified behaviour.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ObjectDisposedException | Thrown is the operation has been disposed. |
ConfigureAwait(IAsyncOperation, Boolean)
Configures an awaiter used to await this operation.
Declaration
public static AsyncAwaitable ConfigureAwait(this IAsyncOperation op, bool continueOnCapturedContext)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to await. |
| Boolean | continueOnCapturedContext | If true attempts to marshal the continuation back to the original context captured. |
Returns
| Type | Description |
|---|---|
| AsyncAwaitable | An object that can be used to await the operation. |
ConfigureAwait(IAsyncOperation, AsyncCallbackOptions)
Configures an awaiter used to await this operation.
Declaration
public static AsyncAwaitable ConfigureAwait(this IAsyncOperation op, AsyncCallbackOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to await. |
| AsyncCallbackOptions | options | Specifies continuation options. |
Returns
| Type | Description |
|---|---|
| AsyncAwaitable | An object that can be used to await the operation. |
ConfigureAwait<TResult>(IAsyncOperation<TResult>, Boolean)
Configures an awaiter used to await this operation.
Declaration
public static AsyncAwaitable<TResult> ConfigureAwait<TResult>(this IAsyncOperation<TResult> op, bool continueOnCapturedContext)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to await. |
| Boolean | continueOnCapturedContext | If true attempts to marshal the continuation back to the original context captured. |
Returns
| Type | Description |
|---|---|
| AsyncAwaitable<TResult> | An object that can be used to await the operation. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
ConfigureAwait<TResult>(IAsyncOperation<TResult>, AsyncCallbackOptions)
Configures an awaiter used to await this operation.
Declaration
public static AsyncAwaitable<TResult> ConfigureAwait<TResult>(this IAsyncOperation<TResult> op, AsyncCallbackOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to await. |
| AsyncCallbackOptions | options | Specifies continuation options. |
Returns
| Type | Description |
|---|---|
| AsyncAwaitable<TResult> | An object that can be used to await the operation. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
ContinueWith(IAsyncOperation, Action<IAsyncOperation, Object>, Object)
Creates a continuation that executes when the target IAsyncOperation completes.
Declaration
public static IAsyncOperation ContinueWith(this IAsyncOperation op, Action<IAsyncOperation, object> action, object userState)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to continue. |
| System.Action<IAsyncOperation, Object> | action | An action to run when the |
| Object | userState | A user-defined state object that is passed as second argument to |
Returns
| Type | Description |
|---|---|
| IAsyncOperation | An operation that is executed after |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith(IAsyncOperation, Action<IAsyncOperation, Object>, Object, AsyncContinuationOptions)
Creates a continuation that executes when the target IAsyncOperation completes.
Declaration
public static IAsyncOperation ContinueWith(this IAsyncOperation op, Action<IAsyncOperation, object> action, object userState, AsyncContinuationOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to continue. |
| System.Action<IAsyncOperation, Object> | action | An action to run when the |
| Object | userState | A user-defined state object that is passed as second argument to |
| AsyncContinuationOptions | options | Options for when the |
Returns
| Type | Description |
|---|---|
| IAsyncOperation | An operation that is executed after |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith(IAsyncOperation, Action<IAsyncOperation>)
Creates a continuation that executes when the target IAsyncOperation completes.
Declaration
public static IAsyncOperation ContinueWith(this IAsyncOperation op, Action<IAsyncOperation> action)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to continue. |
| System.Action<IAsyncOperation> | action | An action to run when the |
Returns
| Type | Description |
|---|---|
| IAsyncOperation | An operation that is executed after |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith(IAsyncOperation, Action<IAsyncOperation>, AsyncContinuationOptions)
Creates a continuation that executes when the target IAsyncOperation completes.
Declaration
public static IAsyncOperation ContinueWith(this IAsyncOperation op, Action<IAsyncOperation> action, AsyncContinuationOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to continue. |
| System.Action<IAsyncOperation> | action | An action to run when the |
| AsyncContinuationOptions | options | Options for when the |
Returns
| Type | Description |
|---|---|
| IAsyncOperation | An operation that is executed after |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith<TResult>(IAsyncOperation, Func<IAsyncOperation, TResult>)
Creates a continuation that executes when the target IAsyncOperation completes.
Declaration
public static IAsyncOperation<TResult> ContinueWith<TResult>(this IAsyncOperation op, Func<IAsyncOperation, TResult> action)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to continue. |
| System.Func<IAsyncOperation, TResult> | action | An action to run when the |
Returns
| Type | Description |
|---|---|
| IAsyncOperation<TResult> | An operation that is executed after |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith<TResult>(IAsyncOperation, Func<IAsyncOperation, TResult>, AsyncContinuationOptions)
Creates a continuation that executes when the target IAsyncOperation completes.
Declaration
public static IAsyncOperation<TResult> ContinueWith<TResult>(this IAsyncOperation op, Func<IAsyncOperation, TResult> action, AsyncContinuationOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to continue. |
| System.Func<IAsyncOperation, TResult> | action | An action to run when the |
| AsyncContinuationOptions | options | Options for when the |
Returns
| Type | Description |
|---|---|
| IAsyncOperation<TResult> | An operation that is executed after |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith<TResult>(IAsyncOperation, Func<IAsyncOperation, Object, TResult>, Object)
Creates a continuation that executes when the target IAsyncOperation completes.
Declaration
public static IAsyncOperation<TResult> ContinueWith<TResult>(this IAsyncOperation op, Func<IAsyncOperation, object, TResult> action, object userState)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to continue. |
| System.Func<IAsyncOperation, Object, TResult> | action | An action to run when the |
| Object | userState | A user-defined state object that is passed as second argument to |
Returns
| Type | Description |
|---|---|
| IAsyncOperation<TResult> | An operation that is executed after |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith<TResult>(IAsyncOperation, Func<IAsyncOperation, Object, TResult>, Object, AsyncContinuationOptions)
Creates a continuation that executes when the target IAsyncOperation completes.
Declaration
public static IAsyncOperation<TResult> ContinueWith<TResult>(this IAsyncOperation op, Func<IAsyncOperation, object, TResult> action, object userState, AsyncContinuationOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to continue. |
| System.Func<IAsyncOperation, Object, TResult> | action | An action to run when the |
| Object | userState | A user-defined state object that is passed as second argument to |
| AsyncContinuationOptions | options | Options for when the |
Returns
| Type | Description |
|---|---|
| IAsyncOperation<TResult> | An operation that is executed after |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith<TResult>(IAsyncOperation<TResult>, Action<IAsyncOperation<TResult>, Object>, Object)
Creates a continuation that executes when the target IAsyncOperation<TResult> completes.
Declaration
public static IAsyncOperation ContinueWith<TResult>(this IAsyncOperation<TResult> op, Action<IAsyncOperation<TResult>, object> action, object userState)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to continue. |
| System.Action<IAsyncOperation<TResult>, Object> | action | An action to run when the |
| Object | userState | A user-defined state object that is passed as second argument to |
Returns
| Type | Description |
|---|---|
| IAsyncOperation | An operation that is executed after |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith<TResult>(IAsyncOperation<TResult>, Action<IAsyncOperation<TResult>, Object>, Object, AsyncContinuationOptions)
Creates a continuation that executes when the target IAsyncOperation<TResult> completes.
Declaration
public static IAsyncOperation ContinueWith<TResult>(this IAsyncOperation<TResult> op, Action<IAsyncOperation<TResult>, object> action, object userState, AsyncContinuationOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to continue. |
| System.Action<IAsyncOperation<TResult>, Object> | action | An action to run when the |
| Object | userState | A user-defined state object that is passed as second argument to |
| AsyncContinuationOptions | options | Options for when the |
Returns
| Type | Description |
|---|---|
| IAsyncOperation | An operation that is executed after |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith<TResult>(IAsyncOperation<TResult>, Action<IAsyncOperation<TResult>>)
Creates a continuation that executes when the target IAsyncOperation<TResult> completes.
Declaration
public static IAsyncOperation ContinueWith<TResult>(this IAsyncOperation<TResult> op, Action<IAsyncOperation<TResult>> action)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to continue. |
| System.Action<IAsyncOperation<TResult>> | action | An action to run when the |
Returns
| Type | Description |
|---|---|
| IAsyncOperation | An operation that is executed after |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith<TResult>(IAsyncOperation<TResult>, Action<IAsyncOperation<TResult>>, AsyncContinuationOptions)
Creates a continuation that executes when the target IAsyncOperation<TResult> completes.
Declaration
public static IAsyncOperation ContinueWith<TResult>(this IAsyncOperation<TResult> op, Action<IAsyncOperation<TResult>> action, AsyncContinuationOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to continue. |
| System.Action<IAsyncOperation<TResult>> | action | An action to run when the |
| AsyncContinuationOptions | options | Options for when the |
Returns
| Type | Description |
|---|---|
| IAsyncOperation | An operation that is executed after |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith<TResult, TNewResult>(IAsyncOperation<TResult>, Func<IAsyncOperation<TResult>, TNewResult>)
Creates a continuation that executes when the target IAsyncOperation completes.
Declaration
public static IAsyncOperation<TNewResult> ContinueWith<TResult, TNewResult>(this IAsyncOperation<TResult> op, Func<IAsyncOperation<TResult>, TNewResult> action)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to continue. |
| System.Func<IAsyncOperation<TResult>, TNewResult> | action | An action to run when the |
Returns
| Type | Description |
|---|---|
| IAsyncOperation<TNewResult> | An operation that is executed after |
Type Parameters
| Name | Description |
|---|---|
| TResult | |
| TNewResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith<TResult, TNewResult>(IAsyncOperation<TResult>, Func<IAsyncOperation<TResult>, TNewResult>, AsyncContinuationOptions)
Creates a continuation that executes when the target IAsyncOperation completes.
Declaration
public static IAsyncOperation<TNewResult> ContinueWith<TResult, TNewResult>(this IAsyncOperation<TResult> op, Func<IAsyncOperation<TResult>, TNewResult> action, AsyncContinuationOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to continue. |
| System.Func<IAsyncOperation<TResult>, TNewResult> | action | An action to run when the |
| AsyncContinuationOptions | options | Options for when the |
Returns
| Type | Description |
|---|---|
| IAsyncOperation<TNewResult> | An operation that is executed after |
Type Parameters
| Name | Description |
|---|---|
| TResult | |
| TNewResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith<TResult, TNewResult>(IAsyncOperation<TResult>, Func<IAsyncOperation<TResult>, Object, TNewResult>, Object)
Creates a continuation that executes when the target IAsyncOperation completes.
Declaration
public static IAsyncOperation<TNewResult> ContinueWith<TResult, TNewResult>(this IAsyncOperation<TResult> op, Func<IAsyncOperation<TResult>, object, TNewResult> action, object userState)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to continue. |
| System.Func<IAsyncOperation<TResult>, Object, TNewResult> | action | An action to run when the |
| Object | userState | A user-defined state object that is passed as second argument to |
Returns
| Type | Description |
|---|---|
| IAsyncOperation<TNewResult> | An operation that is executed after |
Type Parameters
| Name | Description |
|---|---|
| TResult | |
| TNewResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceContinueWith<TResult, TNewResult>(IAsyncOperation<TResult>, Func<IAsyncOperation<TResult>, Object, TNewResult>, Object, AsyncContinuationOptions)
Creates a continuation that executes when the target IAsyncOperation completes.
Declaration
public static IAsyncOperation<TNewResult> ContinueWith<TResult, TNewResult>(this IAsyncOperation<TResult> op, Func<IAsyncOperation<TResult>, object, TNewResult> action, object userState, AsyncContinuationOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to continue. |
| System.Func<IAsyncOperation<TResult>, Object, TNewResult> | action | An action to run when the |
| Object | userState | A user-defined state object that is passed as second argument to |
| AsyncContinuationOptions | options | Options for when the |
Returns
| Type | Description |
|---|---|
| IAsyncOperation<TNewResult> | An operation that is executed after |
Type Parameters
| Name | Description |
|---|---|
| TResult | |
| TNewResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the |
See Also
| Improve this Doc View SourceGetAwaiter(IAsyncOperation)
Returns the operation awaiter. This method is intended for compiler use only.
Declaration
public static AsyncAwaiter GetAwaiter(this IAsyncOperation op)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to await. |
Returns
| Type | Description |
|---|---|
| AsyncAwaiter | An object that can be used to await the operation. |
GetAwaiter<TResult>(IAsyncOperation<TResult>)
Returns the operation awaiter. This method is intended for compiler use only.
Declaration
public static AsyncAwaiter<TResult> GetAwaiter<TResult>(this IAsyncOperation<TResult> op)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to await. |
Returns
| Type | Description |
|---|---|
| AsyncAwaiter<TResult> | An object that can be used to await the operation. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Join(IAsyncOperation)
Waits for the IAsyncOperation to complete execution. After that rethrows the operation exception (if any).
Declaration
public static void Join(this IAsyncOperation op)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to join. |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
Join(IAsyncOperation, Int32)
Waits for the IAsyncOperation to complete execution within a specified number of milliseconds. After that rethrows the operation exception (if any).
Declaration
public static void Join(this IAsyncOperation op, int millisecondsTimeout)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to wait for. |
| Int32 | millisecondsTimeout | The number of milliseconds to wait, or Infinite (-1) to wait indefinitely. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| TimeoutException | Thrown if the operation did not completed within |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
Join(IAsyncOperation, Int32, CancellationToken)
Waits for the IAsyncOperation to complete execution within a specified number of milliseconds. After that rethrows the operation exception (if any). The wait terminates if a timeout interval elapses or a cancellation token is canceled before the operation completes.
Declaration
public static void Join(this IAsyncOperation op, int millisecondsTimeout, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to wait for. |
| Int32 | millisecondsTimeout | The number of milliseconds to wait, or Infinite (-1) to wait indefinitely. |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the operation to complete. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| TimeoutException | Thrown if the operation did not completed within |
| OperationCanceledException | The |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceJoin(IAsyncOperation, CancellationToken)
Waits for the IAsyncOperation to complete execution. After that rethrows the operation exception (if any). The wait terminates if a cancellation token is canceled before the operation completes.
Declaration
public static void Join(this IAsyncOperation op, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to join. |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the operation to complete. |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | The |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceJoin(IAsyncOperation, TimeSpan)
Waits for the IAsyncOperation to complete execution within a specified timeout. After that rethrows the operation exception (if any).
Declaration
public static void Join(this IAsyncOperation op, TimeSpan timeout)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to wait for. |
| TimeSpan | timeout | A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| TimeoutException | Thrown if the operation did not completed within |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
Join(IAsyncOperation, TimeSpan, CancellationToken)
Waits for the IAsyncOperation to complete execution within a specified timeout. After that rethrows the operation exception (if any). The wait terminates if a timeout interval elapses or a cancellation token is canceled before the operation completes.
Declaration
public static void Join(this IAsyncOperation op, TimeSpan timeout, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to wait for. |
| TimeSpan | timeout | A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely. |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the operation to complete. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| TimeoutException | Thrown if the operation did not completed within |
| OperationCanceledException | The |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceJoin<TResult>(IAsyncOperation<TResult>)
Waits for the IAsyncOperation<TResult> to complete execution. After that rethrows the operation exception (if any).
Declaration
public static TResult Join<TResult>(this IAsyncOperation<TResult> op)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to join. |
Returns
| Type | Description |
|---|---|
| TResult | The operation result. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
Join<TResult>(IAsyncOperation<TResult>, Int32)
Waits for the IAsyncOperation<TResult> to complete execution within a specified number of milliseconds. After that rethrows the operation exception (if any).
Declaration
public static TResult Join<TResult>(this IAsyncOperation<TResult> op, int millisecondsTimeout)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to wait for. |
| Int32 | millisecondsTimeout | The number of milliseconds to wait, or Infinite (-1) to wait indefinitely. |
Returns
| Type | Description |
|---|---|
| TResult | The operation result. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| TimeoutException | Thrown if the operation did not completed within |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
Join<TResult>(IAsyncOperation<TResult>, Int32, CancellationToken)
Waits for the IAsyncOperation<TResult> to complete execution within a specified number of milliseconds. After that rethrows the operation exception (if any). The wait terminates if a timeout interval elapses or a cancellation token is canceled before the operation completes.
Declaration
public static TResult Join<TResult>(this IAsyncOperation<TResult> op, int millisecondsTimeout, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to wait for. |
| Int32 | millisecondsTimeout | The number of milliseconds to wait, or Infinite (-1) to wait indefinitely. |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the operation to complete. |
Returns
| Type | Description |
|---|---|
| TResult | The operation result. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| TimeoutException | Thrown if the operation did not completed within |
| OperationCanceledException | The |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceJoin<TResult>(IAsyncOperation<TResult>, CancellationToken)
Waits for the IAsyncOperation<TResult> to complete execution. After that rethrows the operation exception (if any). The wait terminates if a cancellation token is canceled before the operation completes.
Declaration
public static TResult Join<TResult>(this IAsyncOperation<TResult> op, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to join. |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the operation to complete. |
Returns
| Type | Description |
|---|---|
| TResult | The operation result. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | The |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceJoin<TResult>(IAsyncOperation<TResult>, TimeSpan)
Waits for the IAsyncOperation<TResult> to complete execution within a specified timeout. After that rethrows the operation exception (if any).
Declaration
public static TResult Join<TResult>(this IAsyncOperation<TResult> op, TimeSpan timeout)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to wait for. |
| TimeSpan | timeout | A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely. |
Returns
| Type | Description |
|---|---|
| TResult | The operation result. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| TimeoutException | Thrown if the operation did not completed within |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
Join<TResult>(IAsyncOperation<TResult>, TimeSpan, CancellationToken)
Waits for the IAsyncOperation<TResult> to complete execution within a specified timeout. After that rethrows the operation exception (if any). The wait terminates if a timeout interval elapses or a cancellation token is canceled before the operation completes.
Declaration
public static TResult Join<TResult>(this IAsyncOperation<TResult> op, TimeSpan timeout, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The operation to wait for. |
| TimeSpan | timeout | A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely. |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the operation to complete. |
Returns
| Type | Description |
|---|---|
| TResult | The operation result. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| TimeoutException | Thrown if the operation did not completed within |
| OperationCanceledException | The |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceSetCanceled(IAsyncCompletionSource)
Transitions the underlying IAsyncOperation into the Canceled state.
Declaration
public static void SetCanceled(this IAsyncCompletionSource completionSource)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncCompletionSource | completionSource | The completion source instance. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if the transition fails. |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceSetCanceled<TResult>(IAsyncCompletionSource<TResult>)
Transitions the underlying IAsyncOperation<TResult> into the Canceled state.
Declaration
public static void SetCanceled<TResult>(this IAsyncCompletionSource<TResult> completionSource)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncCompletionSource<TResult> | completionSource | The completion source instance. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if the transition fails. |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
SetCompleted(IAsyncCompletionSource)
Transitions the underlying IAsyncOperation into the RanToCompletion state.
Declaration
public static void SetCompleted(this IAsyncCompletionSource completionSource)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncCompletionSource | completionSource | The completion source instance. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if the transition fails. |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceSetException(IAsyncCompletionSource, Exception)
Transitions the underlying IAsyncOperation into the Faulted state.
Declaration
public static void SetException(this IAsyncCompletionSource completionSource, Exception exception)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncCompletionSource | completionSource | The completion source instance. |
| Exception | exception | An exception that caused the operation to end prematurely. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| InvalidOperationException | Thrown if the transition fails. |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceSetException(IAsyncCompletionSource, String)
Transitions the underlying IAsyncOperation into the Faulted state.
Declaration
public static void SetException(this IAsyncCompletionSource completionSource, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncCompletionSource | completionSource | The completion source instance. |
| String | message | An exception message. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| InvalidOperationException | Thrown if the transition fails. |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
SetException<TResult>(IAsyncCompletionSource<TResult>, Exception)
Transitions the underlying IAsyncOperation<TResult> into the Faulted state.
Declaration
public static void SetException<TResult>(this IAsyncCompletionSource<TResult> completionSource, Exception exception)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncCompletionSource<TResult> | completionSource | The completion source instance. |
| Exception | exception | An exception that caused the operation to end prematurely. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| InvalidOperationException | Thrown if the transition fails. |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
SetException<TResult>(IAsyncCompletionSource<TResult>, String)
Transitions the underlying IAsyncOperation<TResult> into the Faulted state.
Declaration
public static void SetException<TResult>(this IAsyncCompletionSource<TResult> completionSource, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncCompletionSource<TResult> | completionSource | The completion source instance. |
| String | message | An exception message. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| InvalidOperationException | Thrown if the transition fails. |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
SetProgress(IAsyncCompletionSource, Single)
Sets the operation progress value in range [0, 1].
Declaration
public static void SetProgress(this IAsyncCompletionSource completionSource, float progress)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncCompletionSource | completionSource | The completion source instance. |
| Single | progress | The operation progress in range [0, 1]. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown if |
| InvalidOperationException | Thrown if the progress value cannot be set. |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceSetProgress<TResult>(IAsyncCompletionSource<TResult>, Single)
Sets the operation progress value in range [0, 1].
Declaration
public static void SetProgress<TResult>(this IAsyncCompletionSource<TResult> completionSource, float progress)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncCompletionSource<TResult> | completionSource | The completion source instance. |
| Single | progress | The operation progress in range [0, 1]. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown if |
| InvalidOperationException | Thrown if the progress value cannot be set. |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceSetResult<TResult>(IAsyncCompletionSource<TResult>, TResult)
Transitions the underlying IAsyncOperation<TResult> into the RanToCompletion state.
Declaration
public static void SetResult<TResult>(this IAsyncCompletionSource<TResult> completionSource, TResult result)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncCompletionSource<TResult> | completionSource | The completion source instance. |
| TResult | result | The operation result. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if the transition fails. |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
ThrowIfNonSuccess(IAsyncOperation)
Throws if the specified operation is faulted/canceled.
Declaration
public static void ThrowIfNonSuccess(this IAsyncOperation op)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op |
ToTask(IAsyncOperation)
Creates a Task instance matching the source IAsyncOperation.
Declaration
public static Task ToTask(this IAsyncOperation op)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The target operation. |
Returns
| Type | Description |
|---|---|
| Task |
See Also
| Improve this Doc View SourceToTask<TResult>(IAsyncOperation<TResult>)
Creates a Task instance matching the source IAsyncOperation.
Declaration
public static Task<TResult> ToTask<TResult>(this IAsyncOperation<TResult> op)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<TResult> | op | The target operation. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult> |
Type Parameters
| Name | Description |
|---|---|
| TResult |
See Also
| Improve this Doc View SourceTrySetException(IAsyncCompletionSource, String)
Attempts to transition the underlying IAsyncOperation into the Faulted state.
Declaration
public static bool TrySetException(this IAsyncCompletionSource completionSource, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncCompletionSource | completionSource | The completion source instance. |
| String | message | An exception message. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if the attemp was successfull; false otherwise. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
TrySetException<TResult>(IAsyncCompletionSource<TResult>, String)
Attempts to transition the underlying IAsyncOperation<TResult> into the Faulted state.
Declaration
public static bool TrySetException<TResult>(this IAsyncCompletionSource<TResult> completionSource, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncCompletionSource<TResult> | completionSource | The completion source instance. |
| String | message | An exception message. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if the attemp was successfull; false otherwise. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
Unwrap(IAsyncOperation<IAsyncOperation>)
Creates a proxy IAsyncOperation that represents the asynchronous operation of a IAsyncOperation<IAsyncOperation>.
Declaration
public static IAsyncOperation Unwrap(this IAsyncOperation<IAsyncOperation> op)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<IAsyncOperation> | op | The source operation. |
Returns
| Type | Description |
|---|---|
| IAsyncOperation | The unwrapped operation. |
See Also
| Improve this Doc View SourceUnwrap<TResult>(IAsyncOperation<IAsyncOperation<TResult>>)
Creates a proxy IAsyncOperation<TResult> that represents the asynchronous operation of a IAsyncOperation<IAsyncOperation<TResult>>.
Declaration
public static IAsyncOperation<TResult> Unwrap<TResult>(this IAsyncOperation<IAsyncOperation<TResult>> op)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation<IAsyncOperation<TResult>> | op | The source operation. |
Returns
| Type | Description |
|---|---|
| IAsyncOperation<TResult> | The unwrapped operation. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
See Also
| Improve this Doc View SourceWait(IAsyncOperation)
Waits for the IAsyncOperation to complete execution. After that rethrows the operation exception (if any).
Declaration
public static void Wait(this IAsyncOperation op)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to wait for. |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceWait(IAsyncOperation, Int32)
Waits for the IAsyncOperation to complete execution within a specified number of milliseconds. After that rethrows the operation exception (if any).
Declaration
public static bool Wait(this IAsyncOperation op, int millisecondsTimeout)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to wait for. |
| Int32 | millisecondsTimeout | The number of milliseconds to wait, or Infinite (-1) to wait indefinitely. |
Returns
| Type | Description |
|---|---|
| Boolean | true if the operation completed execution within the allotted time; otherwise, false. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceWait(IAsyncOperation, Int32, CancellationToken)
Waits for the IAsyncOperation to complete execution within a specified number of milliseconds. After that rethrows the operation exception (if any). The wait terminates if a timeout interval elapses or a cancellation token is canceled before the operation completes.
Declaration
public static bool Wait(this IAsyncOperation op, int millisecondsTimeout, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to wait for. |
| Int32 | millisecondsTimeout | The number of milliseconds to wait, or Infinite (-1) to wait indefinitely. |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the operation to complete. |
Returns
| Type | Description |
|---|---|
| Boolean | true if the operation completed execution within the allotted time; otherwise, false. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| OperationCanceledException | The |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceWait(IAsyncOperation, CancellationToken)
Waits for the IAsyncOperation to complete execution. After that rethrows the operation exception (if any). The wait terminates if a cancellation token is canceled before the operation completes.
Declaration
public static void Wait(this IAsyncOperation op, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to wait for. |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the operation to complete. |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | Thrown is the operation is disposed. |
| OperationCanceledException | The |
See Also
| Improve this Doc View SourceWait(IAsyncOperation, TimeSpan)
Waits for the IAsyncOperation to complete execution within a specified time interval. After that rethrows the operation exception (if any).
Declaration
public static bool Wait(this IAsyncOperation op, TimeSpan timeout)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to wait for. |
| TimeSpan | timeout | A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely. |
Returns
| Type | Description |
|---|---|
| Boolean | true if the operation completed execution within the allotted time; otherwise, false. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceWait(IAsyncOperation, TimeSpan, CancellationToken)
Waits for the IAsyncOperation to complete execution within a specified time interval. After that rethrows the operation exception (if any). The wait terminates if a timeout interval elapses or a cancellation token is canceled before the operation completes.
Declaration
public static bool Wait(this IAsyncOperation op, TimeSpan timeout, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | The operation to wait for. |
| TimeSpan | timeout | A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely. |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the operation to complete. |
Returns
| Type | Description |
|---|---|
| Boolean | true if the operation completed execution within the allotted time; otherwise, false. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| OperationCanceledException | The |
| ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceWithCancellation(IAsyncOperation, CancellationToken)
Registers a CancellationToken that can be used to cancel the specified operation.
Declaration
public static IAsyncOperation WithCancellation(this IAsyncOperation op, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncOperation | op | An operation to register |
| CancellationToken | cancellationToken | A cancellation token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| IAsyncOperation | Returns the target operation. |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Thrown if the target operation does not support cancellation. |