System.Threading.Tasks.TaskCompletionSource<TResult> Class

Represents the producer side of a System.Threading.Tasks.Task`1 unbound to a delegate, providing access to the consumer side through the TaskCompletionSource`1.Task property.

See Also: TaskCompletionSource<TResult> Members


public class TaskCompletionSource<TResult>

Type Parameters

Documentation for this section has not yet been entered.


In many scenarios, it is useful to enable a System.Threading.Tasks.Task`1 to represent an external asynchronous operation. System.Threading.Tasks.TaskCompletionSource`1 is provided for this purpose. It enables the creation of a task that can be handed out to consumers, and those consumers can use the members of the task as they would any other. However, unlike most tasks, the state of a task created by a TaskCompletionSource is controlled explicitly by the methods on TaskCompletionSource. This enables the completion of the external asynchronous operation to be propagated to the underlying Task. The separation also ensures that consumers are not able to transition the state without access to the corresponding TaskCompletionSource. For more information, see the entry tp:// in the Parallel Programming with .NET blog.

The tp:// also contain examples of how to use System.Threading.Tasks.TaskCompletionSource`1.


Namespace: System.Threading.Tasks
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: