Show / Hide Table of Contents

Interface IAsyncOperationCallbacks

Defines basic callback management tools for IAsyncOperation.

Namespace: UnityFx.Async
Assembly: UnityFx.Async-netstandard2.0.dll
Syntax
public interface IAsyncOperationCallbacks

Methods

| Improve this Doc View Source

AddCompletionCallback(Object, SynchronizationContext)

Adds a completion callback to be executed after the operation has completed. If the operation is completed callback is invoked on the syncContext specified. Throwing an exception from the callback causes unspecified behaviour. The method is not intended to be used by user code. Do not use if not sure.

Declaration
void AddCompletionCallback(object callback, SynchronizationContext syncContext)
Parameters
Type Name Description
Object callback

The callback to be executed when the operation has completed. Can be one of Action, System.Action<T> (with IAsyncOperation argument type), AsyncCallback, IAsyncContinuation or AsyncCompletedEventHandler.

SynchronizationContext syncContext

If not null method attempts to marshal the continuation to the synchronization context. Otherwise the callback is invoked on a thread that initiated the operation completion.

Remarks

The callback is invoked on a SynchronizationContext specified.

Exceptions
Type Condition
ArgumentNullException

Thrown if callback is null.

ObjectDisposedException

Thrown is the operation has been disposed.

See Also
AddProgressCallback(Object, SynchronizationContext)
RemoveCallback(Object)
| Improve this Doc View Source

AddProgressCallback(Object, SynchronizationContext)

Adds a callback to be executed when the operation progress has changed. If the operation is completed callback is invoked on the syncContext specified. Throwing an exception from the callback might cause unspecified behaviour. The method is not intended to be used by user code. Do not use if not sure.

Declaration
void AddProgressCallback(object callback, SynchronizationContext syncContext)
Parameters
Type Name Description
Object callback

The callback to be executed when the operation progress has changed.

SynchronizationContext syncContext

If not null method attempts to marshal the continuation to the synchronization context. Otherwise the callback is invoked on a thread that initiated the operation.

Remarks

The callback is invoked on a SynchronizationContext specified.

Exceptions
Type Condition
ArgumentNullException

Thrown if callback is null.

ObjectDisposedException

Thrown is the operation has been disposed.

See Also
AddCompletionCallback(Object, SynchronizationContext)
RemoveCallback(Object)
| Improve this Doc View Source

RemoveCallback(Object)

Removes an existing completion/progress callback.

Declaration
bool RemoveCallback(object callback)
Parameters
Type Name Description
Object callback

The callback to remove. Can be null.

Returns
Type Description
Boolean

Returns true if callback was removed; false otherwise.

See Also
AddCompletionCallback(Object, SynchronizationContext)
AddProgressCallback(Object, SynchronizationContext)

Events

| Improve this Doc View Source

Completed

Raised when the operation is completed.

Declaration
event AsyncCompletedEventHandler Completed
Event Type
Type Description
AsyncCompletedEventHandler
Remarks

The event handler is invoked on a thread that registered it (if it has a SynchronizationContext attached). If the operation is already completed the event handler is called synchronously. Throwing an exception from the event handler might cause unspecified behaviour.

Exceptions
Type Condition
ArgumentNullException

Thrown if the delegate being registered is null.

ObjectDisposedException

Thrown is the operation has been disposed.

See Also
ProgressChanged
| Improve this Doc View Source

ProgressChanged

Raised when the operation progress is changed.

Declaration
event ProgressChangedEventHandler ProgressChanged
Event Type
Type Description
ProgressChangedEventHandler
Remarks

The event handler is invoked on a thread that registered it (if it has a SynchronizationContext attached). If the operation is already completed the event handler is called synchronously. Throwing an exception from the event handler might cause unspecified behaviour.

Exceptions
Type Condition
ArgumentNullException

Thrown if the delegate being registered is null.

ObjectDisposedException

Thrown is the operation has been disposed.

See Also
Completed

Extension Methods

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)

See Also

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