TaskCompletionSource<TResult> Constructors

Definition

Creates a TaskCompletionSource<TResult> object.

Overloads

TaskCompletionSource<TResult>()

Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs
C#
public TaskCompletionSource();

See also

Applies to

.NET 10 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, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

TaskCompletionSource<TResult>(Object)

Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs

Creates a TaskCompletionSource<TResult> with the specified state.

C#
public TaskCompletionSource(object state);
C#
public TaskCompletionSource(object? state);

Parameters

state
Object

The state to use as the underlying Task<TResult>'s AsyncState.

See also

Applies to

.NET 10 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, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

TaskCompletionSource<TResult>(TaskCreationOptions)

Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs

Creates a TaskCompletionSource<TResult> with the specified options.

C#
public TaskCompletionSource(System.Threading.Tasks.TaskCreationOptions creationOptions);

Parameters

creationOptions
TaskCreationOptions

The options to use when creating the underlying Task<TResult>.

Exceptions

The creationOptions represent options invalid for use with a TaskCompletionSource<TResult>.

Remarks

The Task<TResult> created by this instance and accessible through its Task property will be instantiated using the specified creationOptions.

See also

Applies to

.NET 10 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, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

TaskCompletionSource<TResult>(Object, TaskCreationOptions)

Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs

Creates a TaskCompletionSource<TResult> with the specified state and options.

C#
public TaskCompletionSource(object state, System.Threading.Tasks.TaskCreationOptions creationOptions);
C#
public TaskCompletionSource(object? state, System.Threading.Tasks.TaskCreationOptions creationOptions);

Parameters

state
Object

The state to use as the underlying Task<TResult>'s AsyncState.

creationOptions
TaskCreationOptions

The options to use when creating the underlying Task<TResult>.

Exceptions

The creationOptions represent options invalid for use with a TaskCompletionSource<TResult>.

See also

Applies to

.NET 10 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, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0