System.Threading.Tasks.Extensions
Indicates the type of the async method builder that should be used by a language compiler to
build the attributed type when used as the return type of an async method.
Initializes the .
The of the associated builder.
Gets the of the associated builder.
Represents a builder for asynchronous methods that returns a .
The type of the result.
The to which most operations are delegated.
The result for this builder, if it's completed before any awaits occur.
true if contains the synchronous result for the async method; otherwise, false.
true if the builder should be used for setting/getting the result; otherwise, false.
Creates an instance of the struct.
The initialized instance.
Begins running the builder with the associated state machine.
The type of the state machine.
The state machine instance, passed by reference.
Associates the builder with the specified state machine.
The state machine instance to associate with the builder.
Marks the task as successfully completed.
The result to use to complete the task.
Marks the task as failed and binds the specified exception to the task.
The exception to bind to the task.
Gets the task for this builder.
Schedules the state machine to proceed to the next action when the specified awaiter completes.
The type of the awaiter.
The type of the state machine.
the awaiter
The state machine.
Schedules the state machine to proceed to the next action when the specified awaiter completes.
The type of the awaiter.
The type of the state machine.
the awaiter
The state machine.
Provides an awaitable type that enables configured awaits on a .
The type of the result produced.
The wrapped .
true to attempt to marshal the continuation back to the original context captured; otherwise, false.
Initializes the awaitable.
The wrapped .
true to attempt to marshal the continuation back to the original synchronization context captured; otherwise, false.
Returns an awaiter for this instance.
Provides an awaiter for a .
The value being awaited.
The value to pass to ConfigureAwait.
Initializes the awaiter.
The value to be awaited.
The value to pass to ConfigureAwait.
Gets whether the has completed.
Gets the result of the ValueTask.
Schedules the continuation action for the .
Schedules the continuation action for the .
Provides an awaiter for a .
The value being awaited.
Initializes the awaiter.
The value to be awaited.
Gets whether the has completed.
Gets the result of the ValueTask.
Schedules the continuation action for this ValueTask.
Schedules the continuation action for this ValueTask.
Provides a value type that wraps a and a ,
only one of which is used.
The type of the result.
Methods may return an instance of this value type when it's likely that the result of their
operations will be available synchronously and when the method is expected to be invoked so
frequently that the cost of allocating a new for each call will
be prohibitive.
There are tradeoffs to using a instead of a .
For example, while a can help avoid an allocation in the case where the
successful result is available synchronously, it also contains two fields whereas a
as a reference type is a single field. This means that a method call ends up returning two fields worth of
data instead of one, which is more data to copy. It also means that if a method that returns one of these
is awaited within an async method, the state machine for that async method will be larger due to needing
to store the struct that's two fields instead of a single reference.
Further, for uses other than consuming the result of an asynchronous operation via await,
can lead to a more convoluted programming model, which can in turn actually
lead to more allocations. For example, consider a method that could return either a
with a cached task as a common result or a . If the consumer of the result
wants to use it as a , such as to use with in methods like Task.WhenAll and Task.WhenAny,
the would first need to be converted into a using
, which leads to an allocation that would have been avoided if a cached
had been used in the first place.
As such, the default choice for any asynchronous method should be to return a or
. Only if performance analysis proves it worthwhile should a
be used instead of . There is no non-generic version of
as the Task.CompletedTask property may be used to hand back a successfully completed singleton in the case where
a -returning method completes synchronously and successfully.
The task to be used if the operation completed asynchronously or if it completed synchronously but non-successfully.
The result to be used if the operation completed successfully synchronously.
Initialize the with the result of the successful operation.
The result.
Initialize the with a that represents the operation.
The task.
Returns the hash code for this instance.
Returns a value indicating whether this value is equal to a specified .
Returns a value indicating whether this value is equal to a specified value.
Returns a value indicating whether two values are equal.
Returns a value indicating whether two values are not equal.
Gets a object to represent this ValueTask. It will
either return the wrapped task object if one exists, or it'll manufacture a new
task object to represent the result.
Gets whether the represents a completed operation.
Gets whether the represents a successfully completed operation.
Gets whether the represents a failed operation.
Gets whether the represents a canceled operation.
Gets the result.
Gets an awaiter for this value.
Configures an awaiter for this value.
true to attempt to marshal the continuation back to the captured context; otherwise, false.
Gets a string-representation of this .
Creates a method builder for use with an async method.
The created builder.