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

Syntax

public class TaskCompletionSource<TResult>

Type Parameters

TResult
Documentation for this section has not yet been entered.

Remarks

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://blogs.msdn.com/b/pfxteam/archive/2009/06/02/9685804.aspx in the Parallel Programming with .NET blog.

The tp://go.microsoft.com/fwlink/?LinkID=165717 also contain examples of how to use System.Threading.Tasks.TaskCompletionSource`1.

Requirements

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