ValueTask<TResult> Constructors

Definition

Overloads

ValueTask<TResult>(Task<TResult>)

Initializes a new instance of the ValueTask<TResult> class using the supplied task that represents the operation.

ValueTask<TResult>(TResult)

Initializes a new instance of the ValueTask<TResult> class using the supplied result of a successful operation.

ValueTask<TResult>(IValueTaskSource<TResult>, Int16)

Initializes a new instance of the ValueTask<TResult> class with a IValueTaskSource<TResult> object that represents the operation.

ValueTask<TResult>(Task<TResult>)

Source:
ValueTask.cs
Source:
ValueTask.cs
Source:
ValueTask.cs

Initializes a new instance of the ValueTask<TResult> class using the supplied task that represents the operation.

public ValueTask (System.Threading.Tasks.Task<TResult> task);

Parameters

task
Task<TResult>

The task.

Exceptions

The task argument is null.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1

ValueTask<TResult>(TResult)

Source:
ValueTask.cs
Source:
ValueTask.cs
Source:
ValueTask.cs

Initializes a new instance of the ValueTask<TResult> class using the supplied result of a successful operation.

public ValueTask (TResult result);

Parameters

result
TResult

The result.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1

ValueTask<TResult>(IValueTaskSource<TResult>, Int16)

Source:
ValueTask.cs
Source:
ValueTask.cs
Source:
ValueTask.cs

Initializes a new instance of the ValueTask<TResult> class with a IValueTaskSource<TResult> object that represents the operation.

public ValueTask (System.Threading.Tasks.Sources.IValueTaskSource<TResult> source, short token);

Parameters

source
IValueTaskSource<TResult>

The source.

token
Int16

An opaque value that is passed to the IValueTaskSource.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1