Struct AsyncResultMethodBuilder
Provides a builder for asynchronous methods that return AsyncResult. This type is intended for compiler use only.
Inherited Members
Namespace: UnityFx.Async.CompilerServices
Assembly: UnityFx.Async-netstandard2.0.dll
Syntax
public struct AsyncResultMethodBuilder
Remarks
AsyncResultMethodBuilder is a value type, and thus it is copied by value. Prior to being copied, one of its Task, SetResult(), or SetException(Exception) members must be accessed, or else the copies may end up building distinct AsyncResult instances.
Properties
| Improve this Doc View SourceTask
Gets the AsyncResult for this builder.
Declaration
public AsyncResult Task { get; }
Property Value
Type | Description |
---|---|
AsyncResult | The AsyncResult 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. |
See Also
| Improve this Doc View SourceAwaitUnsafeOnCompleted<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. |
See Also
| Improve this Doc View SourceCreate()
Initializes a new AsyncResultMethodBuilder.
Declaration
public static AsyncResultMethodBuilder Create()
Returns
Type | Description |
---|---|
AsyncResultMethodBuilder | The initialized AsyncResultMethodBuilder. |
SetException(Exception)
Completes the AsyncResult 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. |
See Also
| Improve this Doc View SourceSetResult()
Completes the AsyncResult in the RanToCompletion state.
Declaration
public void SetResult()
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The builder is not initialized. |
InvalidOperationException | The operation has already completed. |
See Also
| Improve this Doc View SourceSetStateMachine(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. |