Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Threading.​Tasks.​TaskCompletionSource`1

Assembly: System.Runtime

Inheritance: object → TaskCompletionSource`1

Represents the producer side of a <see cref="T:System.Threading.Tasks.Task`1" /> unbound to a delegate, providing access to the consumer side through the <see cref="P:System.Threading.Tasks.TaskCompletionSource`1.Task" /> property.

Properties

public Task`1
Task
Gets the <see cref="T:System.Threading.Tasks.Task`1" /> created by this <see cref="T:System.Threading.Tasks.TaskCompletionSource`1" /> .

Methods

public void
SetCanceled​()
Transitions the underlying <see cref="T:System.Threading.Tasks.Task`1" /> into the <see cref="F:System.Threading.Tasks.TaskStatus.Canceled" /> state.
public void
SetCanceled​(CancellationToken cancellationToken)
cancellationToken The cancellation token with which to cancel the <see cref="T:System.Threading.Tasks.Task`1" /> .
Transitions the underlying <see cref="T:System.Threading.Tasks.Task`1" /> into the <see cref="F:System.Threading.Tasks.TaskStatus.Canceled" /> state using the specified token.
public void
SetException​(Collections.Generic.IEnumerable`1 exceptions)
public void
SetException​(Exception exception)
exception The exception to bind to this <see cref="T:System.Threading.Tasks.Task`1" /> .
Transitions the underlying <see cref="T:System.Threading.Tasks.Task`1" /> into the <see cref="F:System.Threading.Tasks.TaskStatus.Faulted" /> state and binds it to a specified exception.
public void
SetFromTask​(Task`1 completedTask)
public void
SetResult​(TResult result)
public bool
TrySetCanceled​()
Returns <see langword="true" /> if the operation was successful; false if the operation was unsuccessful or the object has already been disposed.
Attempts to transition the underlying <see cref="T:System.Threading.Tasks.Task`1" /> into the <see cref="F:System.Threading.Tasks.TaskStatus.Canceled" /> state.
public bool
TrySetCanceled​(CancellationToken cancellationToken)
cancellationToken A cancellation token.
Returns <see langword="true" /> if the operation is successful; otherwise, <see langword="false" /> .
Attempts to transition the underlying <see cref="T:System.Threading.Tasks.Task`1" /> into the <see cref="F:System.Threading.Tasks.TaskStatus.Canceled" /> state and enables a cancellation token to be stored in the canceled task.
public bool
TrySetException​(Collections.Generic.IEnumerable`1 exceptions)
public bool
TrySetException​(Exception exception)
exception The exception to bind to this <see cref="T:System.Threading.Tasks.Task`1" /> .
Returns <see langword="true" /> if the operation was successful; otherwise, <see langword="false" /> .
Attempts to transition the underlying <see cref="T:System.Threading.Tasks.Task`1" /> into the <see cref="F:System.Threading.Tasks.TaskStatus.Faulted" /> state and binds it to a specified exception.
public bool
TrySetFromTask​(Task`1 completedTask)
public bool
TrySetResult​(TResult result)
public bool
Equals​(object obj)
Inherited from object
obj The object to compare with the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
Determines whether the specified object is equal to the current object.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public int
GetHashCode​()
Inherited from object
Returns A hash code for the current object.
Serves as the default hash function.
public Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .
public string
ToString​()
Inherited from object
Returns A string that represents the current object.
Returns a string that represents the current object.