Show / Hide Table of Contents

Class AsyncExtensions

Extension methods for IAsyncOperation and related classes.

Inheritance
Object
AsyncExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: UnityFx.Async
Assembly: UnityFx.Async-netstandard2.0.dll
Syntax
public static class AsyncExtensions

Methods

| Improve this Doc View Source

AddCompletionCallback(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 callback is null.

ObjectDisposedException

Thrown is the operation has been disposed.

| Improve this Doc View Source

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 callback is null.

ObjectDisposedException

Thrown is the operation has been disposed.

| Improve this Doc View Source

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 callback is null.

ObjectDisposedException

Thrown is the operation has been disposed.

| Improve this Doc View Source

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 callback is null.

ObjectDisposedException

Thrown is the operation has been disposed.

| Improve this Doc View Source

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 callback is null.

ObjectDisposedException

Thrown is the operation has been disposed.

| Improve this Doc View Source

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 callback is null.

ObjectDisposedException

Thrown is the operation has been disposed.

| Improve this Doc View Source

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 callback is null.

ObjectDisposedException

Thrown is the operation has been disposed.

| Improve this Doc View Source

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 callback is null.

ObjectDisposedException

Thrown is the operation has been disposed.

| Improve this Doc View Source

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 callback is null.

ObjectDisposedException

Thrown is the operation has been disposed.

| Improve this Doc View Source

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 callback is null.

ObjectDisposedException

Thrown is the operation has been disposed.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

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 op completes.

Object userState

A user-defined state object that is passed as second argument to action.

Returns
Type Description
IAsyncOperation

An operation that is executed after op completes.

Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith(IAsyncOperation, Action<IAsyncOperation, Object>, Object, AsyncContinuationOptions)
| Improve this Doc View Source

ContinueWith(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 op completes.

Object userState

A user-defined state object that is passed as second argument to action.

AsyncContinuationOptions options

Options for when the action is executed.

Returns
Type Description
IAsyncOperation

An operation that is executed after op completes.

Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith(IAsyncOperation, Action<IAsyncOperation, Object>, Object)
| Improve this Doc View Source

ContinueWith(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 op completes.

Returns
Type Description
IAsyncOperation

An operation that is executed after op completes.

Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith(IAsyncOperation, Action<IAsyncOperation>, AsyncContinuationOptions)
| Improve this Doc View Source

ContinueWith(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 op completes.

AsyncContinuationOptions options

Options for when the action is executed.

Returns
Type Description
IAsyncOperation

An operation that is executed after op completes.

Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith(IAsyncOperation, Action<IAsyncOperation>)
| Improve this Doc View Source

ContinueWith<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 op completes.

Returns
Type Description
IAsyncOperation<TResult>

An operation that is executed after op completes.

Type Parameters
Name Description
TResult
Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith<TResult>(IAsyncOperation, Func<IAsyncOperation, TResult>, AsyncContinuationOptions)
| Improve this Doc View Source

ContinueWith<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 op completes.

AsyncContinuationOptions options

Options for when the action is executed.

Returns
Type Description
IAsyncOperation<TResult>

An operation that is executed after op completes.

Type Parameters
Name Description
TResult
Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith<TResult>(IAsyncOperation, Func<IAsyncOperation, TResult>)
| Improve this Doc View Source

ContinueWith<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 op completes.

Object userState

A user-defined state object that is passed as second argument to action.

Returns
Type Description
IAsyncOperation<TResult>

An operation that is executed after op completes.

Type Parameters
Name Description
TResult
Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith<TResult>(IAsyncOperation, Func<IAsyncOperation, Object, TResult>, Object, AsyncContinuationOptions)
| Improve this Doc View Source

ContinueWith<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 op completes.

Object userState

A user-defined state object that is passed as second argument to action.

AsyncContinuationOptions options

Options for when the action is executed.

Returns
Type Description
IAsyncOperation<TResult>

An operation that is executed after op completes.

Type Parameters
Name Description
TResult
Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith<TResult>(IAsyncOperation, Func<IAsyncOperation, Object, TResult>, Object)
| Improve this Doc View Source

ContinueWith<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 op completes.

Object userState

A user-defined state object that is passed as second argument to action.

Returns
Type Description
IAsyncOperation

An operation that is executed after op completes.

Type Parameters
Name Description
TResult
Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith<TResult>(IAsyncOperation<TResult>, Action<IAsyncOperation<TResult>, Object>, Object, AsyncContinuationOptions)
| Improve this Doc View Source

ContinueWith<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 op completes.

Object userState

A user-defined state object that is passed as second argument to action.

AsyncContinuationOptions options

Options for when the action is executed.

Returns
Type Description
IAsyncOperation

An operation that is executed after op completes.

Type Parameters
Name Description
TResult
Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith<TResult>(IAsyncOperation<TResult>, Action<IAsyncOperation<TResult>, Object>, Object)
| Improve this Doc View Source

ContinueWith<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 op completes.

Returns
Type Description
IAsyncOperation

An operation that is executed after op completes.

Type Parameters
Name Description
TResult
Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith<TResult>(IAsyncOperation<TResult>, Action<IAsyncOperation<TResult>>, AsyncContinuationOptions)
| Improve this Doc View Source

ContinueWith<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 op completes.

AsyncContinuationOptions options

Options for when the action is executed.

Returns
Type Description
IAsyncOperation

An operation that is executed after op completes.

Type Parameters
Name Description
TResult
Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith<TResult>(IAsyncOperation<TResult>, Action<IAsyncOperation<TResult>>)
| Improve this Doc View Source

ContinueWith<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 op completes.

Returns
Type Description
IAsyncOperation<TNewResult>

An operation that is executed after op completes.

Type Parameters
Name Description
TResult
TNewResult
Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith<TResult, TNewResult>(IAsyncOperation<TResult>, Func<IAsyncOperation<TResult>, TNewResult>, AsyncContinuationOptions)
| Improve this Doc View Source

ContinueWith<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 op completes.

AsyncContinuationOptions options

Options for when the action is executed.

Returns
Type Description
IAsyncOperation<TNewResult>

An operation that is executed after op completes.

Type Parameters
Name Description
TResult
TNewResult
Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith<TResult, TNewResult>(IAsyncOperation<TResult>, Func<IAsyncOperation<TResult>, TNewResult>)
| Improve this Doc View Source

ContinueWith<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 op completes.

Object userState

A user-defined state object that is passed as second argument to action.

Returns
Type Description
IAsyncOperation<TNewResult>

An operation that is executed after op completes.

Type Parameters
Name Description
TResult
TNewResult
Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith<TResult, TNewResult>(IAsyncOperation<TResult>, Func<IAsyncOperation<TResult>, Object, TNewResult>, Object, AsyncContinuationOptions)
| Improve this Doc View Source

ContinueWith<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 op completes.

Object userState

A user-defined state object that is passed as second argument to action.

AsyncContinuationOptions options

Options for when the action is executed.

Returns
Type Description
IAsyncOperation<TNewResult>

An operation that is executed after op completes.

Type Parameters
Name Description
TResult
TNewResult
Exceptions
Type Condition
ArgumentNullException

Thrown if the action is null.

See Also
ContinueWith<TResult, TNewResult>(IAsyncOperation<TResult>, Func<IAsyncOperation<TResult>, Object, TNewResult>, Object)
| Improve this Doc View Source

GetAwaiter(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.

| Improve this Doc View Source

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
| Improve this Doc View Source

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)
Join(IAsyncOperation, TimeSpan)
Join<TResult>(IAsyncOperation<TResult>)
| Improve this Doc View Source

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

millisecondsTimeout is a negative number other than -1.

TimeoutException

Thrown if the operation did not completed within millisecondsTimeout.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Join(IAsyncOperation)
Join(IAsyncOperation, TimeSpan)
Join<TResult>(IAsyncOperation<TResult>, Int32)
| Improve this Doc View Source

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

millisecondsTimeout is a negative number other than -1.

TimeoutException

Thrown if the operation did not completed within millisecondsTimeout.

OperationCanceledException

The cancellationToken was canceled.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Join(IAsyncOperation, Int32)
| Improve this Doc View Source

Join(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 cancellationToken was canceled.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Join(IAsyncOperation)
| Improve this Doc View Source

Join(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

timeout is a negative number other than -1 milliseconds, or timeout is greater than MaxValue.

TimeoutException

Thrown if the operation did not completed within timeout.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Join(IAsyncOperation)
Join(IAsyncOperation, Int32)
Join<TResult>(IAsyncOperation<TResult>, TimeSpan)
| Improve this Doc View Source

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

timeout is a negative number other than -1 milliseconds, or timeout is greater than MaxValue.

TimeoutException

Thrown if the operation did not completed within timeout.

OperationCanceledException

The cancellationToken was canceled.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Join(IAsyncOperation, TimeSpan)
| Improve this Doc View Source

Join<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)
Join<TResult>(IAsyncOperation<TResult>, TimeSpan)
Join(IAsyncOperation)
| Improve this Doc View Source

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

millisecondsTimeout is a negative number other than -1.

TimeoutException

Thrown if the operation did not completed within millisecondsTimeout.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Join<TResult>(IAsyncOperation<TResult>)
Join<TResult>(IAsyncOperation<TResult>, TimeSpan)
Join(IAsyncOperation, Int32)
| Improve this Doc View Source

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

millisecondsTimeout is a negative number other than -1.

TimeoutException

Thrown if the operation did not completed within millisecondsTimeout.

OperationCanceledException

The cancellationToken was canceled.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Join<TResult>(IAsyncOperation<TResult>, Int32)
| Improve this Doc View Source

Join<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 cancellationToken was canceled.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Join<TResult>(IAsyncOperation<TResult>)
| Improve this Doc View Source

Join<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

timeout is a negative number other than -1 milliseconds, or timeout is greater than MaxValue.

TimeoutException

Thrown if the operation did not completed within timeout.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Join<TResult>(IAsyncOperation<TResult>)
Join<TResult>(IAsyncOperation<TResult>, Int32)
Join(IAsyncOperation, TimeSpan)
| Improve this Doc View Source

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

timeout is a negative number other than -1 milliseconds, or timeout is greater than MaxValue.

TimeoutException

Thrown if the operation did not completed within timeout.

OperationCanceledException

The cancellationToken was canceled.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Join<TResult>(IAsyncOperation<TResult>, TimeSpan)
| Improve this Doc View Source

SetCanceled(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
SetException(IAsyncCompletionSource, Exception)
SetCompleted(IAsyncCompletionSource)
| Improve this Doc View Source

SetCanceled<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
SetException<TResult>(IAsyncCompletionSource<TResult>, Exception)
SetResult<TResult>(IAsyncCompletionSource<TResult>, TResult)
| Improve this Doc View Source

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
SetCanceled(IAsyncCompletionSource)
SetException(IAsyncCompletionSource, Exception)
| Improve this Doc View Source

SetException(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 exception is null.

InvalidOperationException

Thrown if the transition fails.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
SetCanceled(IAsyncCompletionSource)
SetCompleted(IAsyncCompletionSource)
| Improve this Doc View Source

SetException(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 message is null.

InvalidOperationException

Thrown if the transition fails.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
SetException(IAsyncCompletionSource, Exception)
SetCanceled(IAsyncCompletionSource)
SetCompleted(IAsyncCompletionSource)
| Improve this Doc View Source

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 exception is null.

InvalidOperationException

Thrown if the transition fails.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
SetException<TResult>(IAsyncCompletionSource<TResult>, Exception)
SetCanceled<TResult>(IAsyncCompletionSource<TResult>)
SetResult<TResult>(IAsyncCompletionSource<TResult>, TResult)
| Improve this Doc View Source

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 message is null.

InvalidOperationException

Thrown if the transition fails.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
SetException<TResult>(IAsyncCompletionSource<TResult>, Exception)
SetCanceled<TResult>(IAsyncCompletionSource<TResult>)
SetResult<TResult>(IAsyncCompletionSource<TResult>, TResult)
| Improve this Doc View Source

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 progress is not in range [0, 1].

InvalidOperationException

Thrown if the progress value cannot be set.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
SetCompleted(IAsyncCompletionSource)
| Improve this Doc View Source

SetProgress<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 progress is not in range [0, 1].

InvalidOperationException

Thrown if the progress value cannot be set.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
SetResult<TResult>(IAsyncCompletionSource<TResult>, TResult)
| Improve this Doc View Source

SetResult<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
SetCanceled<TResult>(IAsyncCompletionSource<TResult>)
SetException<TResult>(IAsyncCompletionSource<TResult>, Exception)
| Improve this Doc View Source

ThrowIfNonSuccess(IAsyncOperation)

Throws if the specified operation is faulted/canceled.

Declaration
public static void ThrowIfNonSuccess(this IAsyncOperation op)
Parameters
Type Name Description
IAsyncOperation op
| Improve this Doc View Source

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
ToTask<TResult>(IAsyncOperation<TResult>)
| Improve this Doc View Source

ToTask<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
ToTask(IAsyncOperation)
| Improve this Doc View Source

TrySetException(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 message is null.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
SetException(IAsyncCompletionSource, Exception)
SetCanceled(IAsyncCompletionSource)
SetCompleted(IAsyncCompletionSource)
| Improve this Doc View Source

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 message is null.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
SetException<TResult>(IAsyncCompletionSource<TResult>, Exception)
SetCanceled<TResult>(IAsyncCompletionSource<TResult>)
SetResult<TResult>(IAsyncCompletionSource<TResult>, TResult)
| Improve this Doc View Source

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
Unwrap<TResult>(IAsyncOperation<IAsyncOperation<TResult>>)
| Improve this Doc View Source

Unwrap<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
Unwrap(IAsyncOperation<IAsyncOperation>)
| Improve this Doc View Source

Wait(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
Wait(IAsyncOperation, Int32)
Wait(IAsyncOperation, TimeSpan)
| Improve this Doc View Source

Wait(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

millisecondsTimeout is a negative number other than -1.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Wait(IAsyncOperation)
Wait(IAsyncOperation, TimeSpan)
| Improve this Doc View Source

Wait(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

millisecondsTimeout is a negative number other than -1.

OperationCanceledException

The cancellationToken was canceled.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Wait(IAsyncOperation, Int32)
| Improve this Doc View Source

Wait(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 cancellationToken was canceled.

See Also
Wait(IAsyncOperation)
| Improve this Doc View Source

Wait(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

timeout is a negative number other than -1 milliseconds, or timeout is greater than MaxValue.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Wait(IAsyncOperation)
Wait(IAsyncOperation, Int32)
| Improve this Doc View Source

Wait(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

timeout is a negative number other than -1 milliseconds, or timeout is greater than MaxValue.

OperationCanceledException

The cancellationToken was canceled.

ObjectDisposedException

Thrown is the operation is disposed.

See Also
Wait(IAsyncOperation, TimeSpan)
| Improve this Doc View Source

WithCancellation(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 for.

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.

  • Improve this Doc
  • View Source
Back to top Copyright (c) 2017-2018 Alexander Bogarsukov