Show / Hide Table of Contents

Interface IAsyncOperation

Represents the consumer side of an asynchronous operation (promise).

Inherited Members
IAsyncOperationCallbacks.ProgressChanged
IAsyncOperationCallbacks.Completed
IAsyncOperationCallbacks.AddCompletionCallback(Object, SynchronizationContext)
IAsyncOperationCallbacks.AddProgressCallback(Object, SynchronizationContext)
IAsyncOperationCallbacks.RemoveCallback(Object)
IAsyncCancellable.Cancel()
IAsyncResult.AsyncState
IAsyncResult.AsyncWaitHandle
IAsyncResult.CompletedSynchronously
IAsyncResult.IsCompleted
System.IDisposable.Dispose()
Namespace: UnityFx.Async
Assembly: UnityFx.Async-netstandard2.0.dll
Syntax
public interface IAsyncOperation : IAsyncOperationCallbacks, IAsyncCancellable, IAsyncResult, IDisposable
Remarks

The interface defines a read-only consumer side of an asynchronous operation. Basically it provides the operation state information and completion/progress events. It is cancellable so a cancellation request can be issued at any time (without any guarantees though).

Properties

| Improve this Doc View Source

Exception

Gets an exception that caused the operation to end prematurely. If the operation completed successfully or has not yet thrown any exceptions, this will return null.

Declaration
Exception Exception { get; }
Property Value
Type Description
Exception

An exception that caused the operation to end prematurely.

Remarks

Task uses a special aggregate exception for providing generic error information. The library does not allow child operations by design and this fact makes usage of aggregate exceptions a very rare case. This is why we use Exception here.

See Also
IsFaulted
Status
| Improve this Doc View Source

Id

Gets a unique ID for the operation instance.

Declaration
int Id { get; }
Property Value
Type Description
Int32

Unique non-zero identifier of the operation instance.

Remarks

The identifiers might be assigned on demand and do not represent the order in which operations instances were created.

| Improve this Doc View Source

IsCanceled

Gets a value indicating whether the operation completed due to being canceled (i.e. with Canceled status).

Declaration
bool IsCanceled { get; }
Property Value
Type Description
Boolean

A value indicating whether the operation was canceled.

Remarks

If IsCanceled is true, the operation's Status will be equal to Canceled, and its Exception property will be non-null.

See Also
IsCompletedSuccessfully
IsFaulted
Status
| Improve this Doc View Source

IsCompletedSuccessfully

Gets a value indicating whether the operation completed successfully (i.e. with RanToCompletion status).

Declaration
bool IsCompletedSuccessfully { get; }
Property Value
Type Description
Boolean

A value indicating whether the operation completed successfully.

See Also
IsFaulted
IsCanceled
Status
| Improve this Doc View Source

IsFaulted

Gets a value indicating whether the operation completed due to an unhandled exception (i.e. with Faulted status).

Declaration
bool IsFaulted { get; }
Property Value
Type Description
Boolean

A value indicating whether the operation has failed.

Remarks

If IsFaulted is true, the operation's Status will be equal to Faulted, and its Exception property will be non-null.

See Also
Exception
IsCompletedSuccessfully
IsCanceled
Status
| Improve this Doc View Source

Progress

Gets the operation progress [0, 1].

Declaration
float Progress { get; }
Property Value
Type Description
Single

Progress of the operation in range [0, 1].

Remarks

Different operation implementations might provide different progress resolution. Users of this interface can expect 0 value until the operation is started and 1 when it is completed as minimum.

See Also
Status
| Improve this Doc View Source

Status

Gets the operation status identifier.

Declaration
AsyncOperationStatus Status { get; }
Property Value
Type Description
AsyncOperationStatus

Identifier of the operation status.

See Also
IsCompletedSuccessfully
IsFaulted
IsCanceled

Extension Methods

AsyncExtensions.ThrowIfNonSuccess(IAsyncOperation)
AsyncExtensions.WithCancellation(IAsyncOperation, CancellationToken)
AsyncExtensions.Wait(IAsyncOperation)
AsyncExtensions.Wait(IAsyncOperation, Int32)
AsyncExtensions.Wait(IAsyncOperation, TimeSpan)
AsyncExtensions.Wait(IAsyncOperation, CancellationToken)
AsyncExtensions.Wait(IAsyncOperation, Int32, CancellationToken)
AsyncExtensions.Wait(IAsyncOperation, TimeSpan, CancellationToken)
AsyncExtensions.Join(IAsyncOperation)
AsyncExtensions.Join(IAsyncOperation, Int32)
AsyncExtensions.Join(IAsyncOperation, TimeSpan)
AsyncExtensions.Join(IAsyncOperation, CancellationToken)
AsyncExtensions.Join(IAsyncOperation, Int32, CancellationToken)
AsyncExtensions.Join(IAsyncOperation, TimeSpan, CancellationToken)
AsyncExtensions.ContinueWith(IAsyncOperation, Action<IAsyncOperation>)
AsyncExtensions.ContinueWith(IAsyncOperation, Action<IAsyncOperation>, AsyncContinuationOptions)
AsyncExtensions.ContinueWith(IAsyncOperation, Action<IAsyncOperation, Object>, Object)
AsyncExtensions.ContinueWith(IAsyncOperation, Action<IAsyncOperation, Object>, Object, AsyncContinuationOptions)
AsyncExtensions.ContinueWith<TResult>(IAsyncOperation, Func<IAsyncOperation, TResult>)
AsyncExtensions.ContinueWith<TResult>(IAsyncOperation, Func<IAsyncOperation, TResult>, AsyncContinuationOptions)
AsyncExtensions.ContinueWith<TResult>(IAsyncOperation, Func<IAsyncOperation, Object, TResult>, Object)
AsyncExtensions.ContinueWith<TResult>(IAsyncOperation, Func<IAsyncOperation, Object, TResult>, Object, AsyncContinuationOptions)
AsyncExtensions.ToTask(IAsyncOperation)
AsyncExtensions.GetAwaiter(IAsyncOperation)
AsyncExtensions.ConfigureAwait(IAsyncOperation, Boolean)
AsyncExtensions.ConfigureAwait(IAsyncOperation, AsyncCallbackOptions)
AsyncExtensions.AddCompletionCallback(IAsyncOperationCallbacks, Action)
AsyncExtensions.AddCompletionCallback(IAsyncOperationCallbacks, Action, AsyncCallbackOptions)
AsyncExtensions.AddCompletionCallback(IAsyncOperationCallbacks, Action<IAsyncOperation>)
AsyncExtensions.AddCompletionCallback(IAsyncOperationCallbacks, Action<IAsyncOperation>, AsyncCallbackOptions)
AsyncExtensions.AddCompletionCallback(IAsyncOperationCallbacks, IAsyncContinuation)
AsyncExtensions.AddCompletionCallback(IAsyncOperationCallbacks, IAsyncContinuation, AsyncCallbackOptions)
AsyncExtensions.AddProgressCallback(IAsyncOperationCallbacks, Action<Single>)
AsyncExtensions.AddProgressCallback(IAsyncOperationCallbacks, Action<Single>, AsyncCallbackOptions)
AsyncExtensions.AddProgressCallback(IAsyncOperationCallbacks, IProgress<Single>)
AsyncExtensions.AddProgressCallback(IAsyncOperationCallbacks, IProgress<Single>, AsyncCallbackOptions)
IAsyncResultExtensions.ToEnum(IAsyncResult)
IAsyncResultExtensions.SpinUntilCompleted(IAsyncResult)
IAsyncResultExtensions.SpinUntilCompleted(IAsyncResult, Int32)
IAsyncResultExtensions.SpinUntilCompleted(IAsyncResult, TimeSpan)
IAsyncResultExtensions.SpinUntilCompleted(IAsyncResult, CancellationToken)
IAsyncResultExtensions.SpinUntilCompleted(IAsyncResult, Int32, CancellationToken)
IAsyncResultExtensions.SpinUntilCompleted(IAsyncResult, TimeSpan, CancellationToken)
PromiseExtensions.Then(IAsyncOperation, Action)
PromiseExtensions.Then(IAsyncOperation, Func<IAsyncOperation>)
PromiseExtensions.Then<TResult>(IAsyncOperation, Func<IAsyncOperation<TResult>>)
PromiseExtensions.Then(IAsyncOperation, Action, Action<Exception>)
PromiseExtensions.Then(IAsyncOperation, Func<IAsyncOperation>, Action<Exception>)
PromiseExtensions.ThenAll(IAsyncOperation, Func<IEnumerable<IAsyncOperation>>)
PromiseExtensions.ThenAll<T>(IAsyncOperation, Func<IEnumerable<IAsyncOperation<T>>>)
PromiseExtensions.ThenAny(IAsyncOperation, Func<IEnumerable<IAsyncOperation>>)
PromiseExtensions.ThenAny<TResult>(IAsyncOperation, Func<IEnumerable<IAsyncOperation<TResult>>>)
PromiseExtensions.ThenSequence(IAsyncOperation, Func<IEnumerable<Func<IAsyncOperation>>>)
PromiseExtensions.ThenSequence(IAsyncOperation, Func<Func<IAsyncOperation>[]>)
PromiseExtensions.Rebind<TResult>(IAsyncOperation, Func<TResult>)
PromiseExtensions.Catch(IAsyncOperation, Action<Exception>)
PromiseExtensions.Catch<TException>(IAsyncOperation, Action<TException>)
PromiseExtensions.Finally(IAsyncOperation, Action)
PromiseExtensions.Done(IAsyncOperation, Action)
PromiseExtensions.Done(IAsyncOperation, Action, Action<Exception>)
PromiseExtensions.Done(IAsyncOperation)

See Also

Task
IAsyncCompletionSource
IAsyncOperation<TResult>
AsyncResult
  • Improve this Doc
  • View Source
Back to top Copyright (c) 2017-2018 Alexander Bogarsukov