Struct SpawningAsyncTaskMethodBuilder
When applied to async method using AsyncMethodBuilderAttribute attribute, spawns method execution as a new work item in the thread pool, i.e. in parallel.
Inherited Members
Namespace: DotNext.Runtime.CompilerServices
Assembly: DotNext.dll
Syntax
public struct SpawningAsyncTaskMethodBuilder
Remarks
This builder has the same effect as Run(Func<Task>) but consumes less memory.
Constructors
| Edit this page View SourceSpawningAsyncTaskMethodBuilder()
When applied to async method using AsyncMethodBuilderAttribute attribute, spawns method execution as a new work item in the thread pool, i.e. in parallel.
Declaration
public SpawningAsyncTaskMethodBuilder()
Remarks
This builder has the same effect as Run(Func<Task>) but consumes less memory.
Properties
| Edit this page View SourceTask
Gets the task representing the builder's asynchronous operation.
Declaration
public Task Task { get; }
Property Value
Type | Description |
---|---|
Task |
Methods
| Edit this page 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 : notnull, INotifyCompletion where TStateMachine : notnull, IAsyncStateMachine
Parameters
Type | Name | Description |
---|---|---|
TAwaiter | awaiter | The awaiter. |
TStateMachine | stateMachine | The state machine. |
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; without capturing execution context.
Declaration
public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : notnull, ICriticalNotifyCompletion where TStateMachine : notnull, IAsyncStateMachine
Parameters
Type | Name | Description |
---|---|---|
TAwaiter | awaiter | The awaiter. |
TStateMachine | stateMachine | The state machine. |
Type Parameters
Name | Description |
---|---|
TAwaiter | Specifies the type of the awaiter. |
TStateMachine | Specifies the type of the state machine. |
Create()
Initializes a new builder.
Declaration
public static SpawningAsyncTaskMethodBuilder Create()
Returns
Type | Description |
---|---|
SpawningAsyncTaskMethodBuilder | A new builder. |
SetException(Exception)
Completes asynchronous operation unsuccessfully.
Declaration
public void SetException(Exception e)
Parameters
Type | Name | Description |
---|---|---|
Exception | e | The exception to be thrown by the asynchronous method associated with this builder. |
SetResult()
Completes asynchronous operation successfully.
Declaration
public void SetResult()
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 : notnull, 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. |