Class AsyncResult<TResult>
A lightweight net35-compatible asynchronous operation that can return a value.
Inherited Members
Namespace: UnityFx.Async
Assembly: UnityFx.Async-netstandard2.0.dll
Syntax
public class AsyncResult<TResult> : AsyncResult, IAsyncContinuation, IEnumerator, IAsyncOperation<TResult>, IAsyncOperation, IAsyncOperationCallbacks, IAsyncCancellable, IAsyncResult, IDisposable, IObservable<TResult>
Type Parameters
Name | Description |
---|---|
TResult | Type of the operation result value. |
Constructors
| Improve this Doc View SourceAsyncResult()
Initializes a new instance of the AsyncResult<TResult> class.
Declaration
public AsyncResult()
AsyncResult(AsyncCallback, Object)
Initializes a new instance of the AsyncResult<TResult> class.
Declaration
public AsyncResult(AsyncCallback asyncCallback, object asyncState)
Parameters
Type | Name | Description |
---|---|---|
AsyncCallback | asyncCallback | User-defined completion callback. |
Object | asyncState | User-defined data to assosiate with the operation. |
AsyncResult(AsyncCreationOptions)
Initializes a new instance of the AsyncResult<TResult> class.
Declaration
public AsyncResult(AsyncCreationOptions options)
Parameters
Type | Name | Description |
---|---|---|
AsyncCreationOptions | options | The AsyncCreationOptions used to customize the operation's behavior. |
AsyncResult(AsyncCreationOptions, AsyncCallback, Object)
Initializes a new instance of the AsyncResult<TResult> class.
Declaration
public AsyncResult(AsyncCreationOptions options, AsyncCallback asyncCallback, object asyncState)
Parameters
Type | Name | Description |
---|---|---|
AsyncCreationOptions | options | The AsyncCreationOptions used to customize the operation's behavior. |
AsyncCallback | asyncCallback | User-defined completion callback. |
Object | asyncState | User-defined data to assosiate with the operation. |
AsyncResult(AsyncCreationOptions, Object)
Initializes a new instance of the AsyncResult<TResult> class.
Declaration
public AsyncResult(AsyncCreationOptions options, object asyncState)
Parameters
Type | Name | Description |
---|---|---|
AsyncCreationOptions | options | The AsyncCreationOptions used to customize the operation's behavior. |
Object | asyncState | User-defined data to assosiate with the operation. |
AsyncResult(AsyncOperationStatus)
Initializes a new instance of the AsyncResult<TResult> class.
Declaration
public AsyncResult(AsyncOperationStatus status)
Parameters
Type | Name | Description |
---|---|---|
AsyncOperationStatus | status | Status value of the operation. |
AsyncResult(AsyncOperationStatus, AsyncCallback, Object)
Initializes a new instance of the AsyncResult<TResult> class.
Declaration
public AsyncResult(AsyncOperationStatus status, AsyncCallback asyncCallback, object asyncState)
Parameters
Type | Name | Description |
---|---|---|
AsyncOperationStatus | status | Status value of the operation. |
AsyncCallback | asyncCallback | User-defined completion callback. |
Object | asyncState | User-defined data to assosiate with the operation. |
AsyncResult(AsyncOperationStatus, Object)
Initializes a new instance of the AsyncResult<TResult> class.
Declaration
public AsyncResult(AsyncOperationStatus status, object asyncState)
Parameters
Type | Name | Description |
---|---|---|
AsyncOperationStatus | status | Status value of the operation. |
Object | asyncState | User-defined data to assosiate with the operation. |
AsyncResult(AsyncOperationStatus, AsyncCreationOptions)
Initializes a new instance of the AsyncResult<TResult> class.
Declaration
public AsyncResult(AsyncOperationStatus status, AsyncCreationOptions options)
Parameters
Type | Name | Description |
---|---|---|
AsyncOperationStatus | status | Status value of the operation. |
AsyncCreationOptions | options | The AsyncCreationOptions used to customize the operation's behavior. |
AsyncResult(AsyncOperationStatus, AsyncCreationOptions, AsyncCallback, Object)
Initializes a new instance of the AsyncResult<TResult> class.
Declaration
public AsyncResult(AsyncOperationStatus status, AsyncCreationOptions options, AsyncCallback asyncCallback, object asyncState)
Parameters
Type | Name | Description |
---|---|---|
AsyncOperationStatus | status | Status value of the operation. |
AsyncCreationOptions | options | The AsyncCreationOptions used to customize the operation's behavior. |
AsyncCallback | asyncCallback | User-defined completion callback. |
Object | asyncState | User-defined data to assosiate with the operation. |
AsyncResult(AsyncOperationStatus, AsyncCreationOptions, Object)
Initializes a new instance of the AsyncResult<TResult> class.
Declaration
public AsyncResult(AsyncOperationStatus status, AsyncCreationOptions options, object asyncState)
Parameters
Type | Name | Description |
---|---|---|
AsyncOperationStatus | status | Status value of the operation. |
AsyncCreationOptions | options | The AsyncCreationOptions used to customize the operation's behavior. |
Object | asyncState | User-defined data to assosiate with the operation. |
Properties
| Improve this Doc View SourceResult
Gets the operation result value.
Declaration
public TResult Result { get; }
Property Value
Type | Description |
---|---|
TResult | Result of the operation. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if the property is accessed before operation is completed. |
Methods
| Improve this Doc View SourceSubscribe(IObserver<TResult>)
Notifies the provider that an observer is to receive notifications.
Declaration
public IDisposable Subscribe(IObserver<TResult> observer)
Parameters
Type | Name | Description |
---|---|---|
System.IObserver<TResult> | observer | The object that is to receive notifications. |
Returns
Type | Description |
---|---|
IDisposable | A reference to an interface that allows observers to stop receiving notifications before the provider has finished sending them. |
TrySetResult(TResult)
Attempts to transition the operation into the RanToCompletion state.
Declaration
protected bool TrySetResult(TResult result)
Parameters
Type | Name | Description |
---|---|---|
TResult | result | The operation result. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the attemp was successfull; false otherwise. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown is the operation is disposed. |
See Also
| Improve this Doc View SourceTrySetResult(TResult, Boolean)
Attempts to transition the operation into the RanToCompletion state.
Declaration
protected bool TrySetResult(TResult result, bool completedSynchronously)
Parameters
Type | Name | Description |
---|---|---|
TResult | result | The operation result. |
Boolean | completedSynchronously | Value of the CompletedSynchronously property. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the attemp was successfull; false otherwise. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown is the operation is disposed. |