Show / Hide Table of Contents

Struct SpawningAsyncTaskMethodBuilder<TResult>

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
ValueType.Equals(object)
ValueType.GetHashCode()
ValueType.ToString()
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: DotNext.Runtime.CompilerServices
Assembly: DotNext.dll
Syntax
public struct SpawningAsyncTaskMethodBuilder<TResult>
Type Parameters
Name Description
TResult

The type of the value to be returned by asynchronous method.

Remarks

This builder has the same effect as Run<TResult>(Func<Task<TResult>>) but consumes less memory.

Constructors

| Edit this page View Source

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.

Declaration
public SpawningAsyncTaskMethodBuilder()
Remarks

This builder has the same effect as Run<TResult>(Func<Task<TResult>>) but consumes less memory.

Properties

| Edit this page View Source

Task

Gets the task representing the builder's asynchronous operation.

Declaration
public Task<TResult> Task { get; }
Property Value
Type Description
Task<TResult>

Methods

| Edit this page View Source

AwaitOnCompleted<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.

TStateMachine stateMachine

The state machine.

Type Parameters
Name Description
TAwaiter

Specifies the type of the awaiter.

TStateMachine

Specifies the type of the state machine.

| Edit this page View Source

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 : ICriticalNotifyCompletion where TStateMachine : 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.

| Edit this page View Source

Create()

Initializes a new builder.

Declaration
public static SpawningAsyncTaskMethodBuilder<TResult> Create()
Returns
Type Description
SpawningAsyncTaskMethodBuilder<TResult>

A new builder.

| Edit this page View Source

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.

| Edit this page View Source

SetResult(TResult)

Completes asynchronous operation successfully.

Declaration
public void SetResult(TResult result)
Parameters
Type Name Description
TResult result

The result to be returned by the asynchronous method associated with this builder.

| Edit this page View Source

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.

| Edit this page View Source

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.

Extension Methods

BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
Collection.ToAsyncEnumerator<TEnumerator, T>(TEnumerator, CancellationToken)
Collection.ToClassicEnumerator<TEnumerator, T>(TEnumerator)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)
ExpressionBuilder.Const<T>(T)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾