Struct AsyncResultMethodBuilder<TResult>
Provides a builder for asynchronous methods that return AsyncResult<TResult>. This type is intended for compiler use only.
Inherited Members
Namespace: UnityFx.Async.CompilerServices
Assembly: UnityFx.Async-netstandard2.0.dll
Syntax
public struct AsyncResultMethodBuilder<TResult>
Type Parameters
Name | Description |
---|---|
TResult |
Remarks
AsyncResultMethodBuilder<TResult> is a value type, and thus it is copied by value. Prior to being copied, one of its Task, SetResult(TResult), or SetException(Exception) members must be accessed, or else the copies may end up building distinct AsyncResult<TResult> instances.
Properties
| Improve this Doc View SourceTask
Gets the AsyncResult<TResult> for this builder.
Declaration
public AsyncResult<TResult> Task { get; }
Property Value
Type | Description |
---|---|
AsyncResult<TResult> | The AsyncResult<TResult> representing the builder's asynchronous operation. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The builder is not initialized. |
Methods
| Improve this Doc View SourceAwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter, ref TStateMachine)
Schedules the specified state machine to be pushed forward when the specified awaiter completes.
Declaration
public void AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine)where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine
Parameters
Type | Name | Description |
---|---|---|
TAwaiter | awaiter | The awaiter passed by reference. |
TStateMachine | stateMachine | The state machine passed by reference. |
Type Parameters
Name | Description |
---|---|
TAwaiter | Specifies the type of the awaiter. |
TStateMachine | Specifies the type of the state machine. |
AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter, ref TStateMachine)
Schedules the specified state machine to be pushed forward when the specified awaiter completes.
Declaration
public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine)where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine
Parameters
Type | Name | Description |
---|---|---|
TAwaiter | awaiter | The awaiter passed by reference. |
TStateMachine | stateMachine | The state machine passed by reference. |
Type Parameters
Name | Description |
---|---|
TAwaiter | Specifies the type of the awaiter. |
TStateMachine | Specifies the type of the state machine. |
Create()
Initializes a new AsyncResultMethodBuilder<TResult>.
Declaration
public static AsyncResultMethodBuilder<TResult> Create()
Returns
Type | Description |
---|---|
AsyncResultMethodBuilder<TResult> | The initialized AsyncResultMethodBuilder<TResult>. |
SetException(Exception)
Completes the AsyncResult<TResult> in the Faulted state with the specified exception
.
Declaration
public void SetException(Exception exception)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | The Exception to use to fault the operation. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The |
InvalidOperationException | The builder is not initialized. |
InvalidOperationException | The operation has already completed. |
SetResult(TResult)
Completes the AsyncResult<TResult> in the RanToCompletion state.
Declaration
public void SetResult(TResult result)
Parameters
Type | Name | Description |
---|---|---|
TResult | result | The result to use to complete the operation. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The builder is not initialized. |
InvalidOperationException | The operation has already completed. |
SetStateMachine(IAsyncStateMachine)
Associates the builder with the state machine it represents.
Declaration
public void SetStateMachine(IAsyncStateMachine stateMachine)
Parameters
Type | Name | Description |
---|---|---|
IAsyncStateMachine | stateMachine | The heap-allocated state machine object. |
Start<TStateMachine>(ref TStateMachine)
Initiates the builder's execution with the associated state machine.
Declaration
public void Start<TStateMachine>(ref TStateMachine stateMachine)where TStateMachine : IAsyncStateMachine
Parameters
Type | Name | Description |
---|---|---|
TStateMachine | stateMachine | The state machine instance, passed by reference. |
Type Parameters
Name | Description |
---|---|
TStateMachine | Specifies the type of the state machine. |