Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TaskFactory<TResult> Class

Provides support for creating and scheduling Task<TResult> objects.

System.Object
  System.Threading.Tasks.TaskFactory<TResult>

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

public class TaskFactory<TResult>

Type Parameters

TResult

The type of the results that are available though the Task<TResult> objects that are associated with the methods in this class.

The TaskFactory<TResult> type exposes the following members.

  NameDescription
Public methodTaskFactory<TResult>()Initializes a TaskFactory<TResult> instance with the default configuration.
Public methodTaskFactory<TResult>(CancellationToken)Initializes a TaskFactory<TResult> instance with the default configuration.
Public methodTaskFactory<TResult>(TaskScheduler)Initializes a TaskFactory<TResult> instance with the specified configuration.
Public methodTaskFactory<TResult>(TaskCreationOptions, TaskContinuationOptions)Initializes a TaskFactory<TResult> instance with the specified configuration.
Public methodTaskFactory<TResult>(CancellationToken, TaskCreationOptions, TaskContinuationOptions, TaskScheduler)Initializes a TaskFactory<TResult> instance with the specified configuration.
Top

  NameDescription
Public propertyCancellationTokenGets the default CancellationToken of this TaskFactory.
Public propertyContinuationOptionsGets the TaskCreationOptions value of this TaskFactory{TResult}.
Public propertyCreationOptionsGets the TaskCreationOptions value of this TaskFactory{TResult}.
Public propertySchedulerGets the TaskScheduler of this TaskFactory{TResult}.
Top

  NameDescription
Public methodContinueWhenAll(Task[], Func<Task[], TResult>)Creates a continuation Task<TResult> that will be started upon the completion of a set of provided Tasks.
Public methodContinueWhenAll(Task[], Func<Task[], TResult>, CancellationToken)Creates a continuation Task<TResult> that will be started upon the completion of a set of provided Tasks.
Public methodContinueWhenAll(Task[], Func<Task[], TResult>, TaskContinuationOptions)Creates a continuation Task<TResult> that will be started upon the completion of a set of provided Tasks.
Public methodContinueWhenAll(Task[], Func<Task[], TResult>, CancellationToken, TaskContinuationOptions, TaskScheduler)Creates a continuation Task<TResult> that will be started upon the completion of a set of provided Tasks.
Public methodContinueWhenAll<TAntecedentResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>[], TResult>)Creates a continuation Task<TResult> that will be started upon the completion of a set of provided Tasks.
Public methodContinueWhenAll<TAntecedentResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>[], TResult>, CancellationToken)Creates a continuation Task<TResult> that will be started upon the completion of a set of provided Tasks.
Public methodContinueWhenAll<TAntecedentResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>[], TResult>, TaskContinuationOptions)Creates a continuation Task<TResult> that will be started upon the completion of a set of provided Tasks.
Public methodContinueWhenAll<TAntecedentResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>[], TResult>, CancellationToken, TaskContinuationOptions, TaskScheduler)Creates a continuation Task<TResult> that will be started upon the completion of a set of provided Tasks.
Public methodContinueWhenAny(Task[], Func<Task, TResult>)Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.
Public methodContinueWhenAny(Task[], Func<Task, TResult>, CancellationToken)Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.
Public methodContinueWhenAny(Task[], Func<Task, TResult>, TaskContinuationOptions)Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.
Public methodContinueWhenAny(Task[], Func<Task, TResult>, CancellationToken, TaskContinuationOptions, TaskScheduler)Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.
Public methodContinueWhenAny<TAntecedentResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>, TResult>)Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.
Public methodContinueWhenAny<TAntecedentResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>, TResult>, CancellationToken)Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.
Public methodContinueWhenAny<TAntecedentResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>, TResult>, TaskContinuationOptions)Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.
Public methodContinueWhenAny<TAntecedentResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>, TResult>, CancellationToken, TaskContinuationOptions, TaskScheduler)Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodFromAsync(IAsyncResult, Func<IAsyncResult, TResult>)Creates a Task<TResult> that executes an end method function when a specified IAsyncResult completes.
Public methodFromAsync(Func<AsyncCallback, Object, IAsyncResult>, Func<IAsyncResult, TResult>, Object)Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodFromAsync(IAsyncResult, Func<IAsyncResult, TResult>, TaskCreationOptions)Creates a Task<TResult> that executes an end method function when a specified IAsyncResult completes.
Public methodFromAsync(Func<AsyncCallback, Object, IAsyncResult>, Func<IAsyncResult, TResult>, Object, TaskCreationOptions)Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodFromAsync(IAsyncResult, Func<IAsyncResult, TResult>, TaskCreationOptions, TaskScheduler)Creates a Task<TResult> that executes an end method function when a specified IAsyncResult completes.
Public methodFromAsync<TArg1>(Func<TArg1, AsyncCallback, Object, IAsyncResult>, Func<IAsyncResult, TResult>, TArg1, Object)Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodFromAsync<TArg1>(Func<TArg1, AsyncCallback, Object, IAsyncResult>, Func<IAsyncResult, TResult>, TArg1, Object, TaskCreationOptions)Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodFromAsync<TArg1, TArg2>(Func<TArg1, TArg2, AsyncCallback, Object, IAsyncResult>, Func<IAsyncResult, TResult>, TArg1, TArg2, Object)Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodFromAsync<TArg1, TArg2>(Func<TArg1, TArg2, AsyncCallback, Object, IAsyncResult>, Func<IAsyncResult, TResult>, TArg1, TArg2, Object, TaskCreationOptions)Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodFromAsync<TArg1, TArg2, TArg3>(Func<TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>, Func<IAsyncResult, TResult>, TArg1, TArg2, TArg3, Object)Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodFromAsync<TArg1, TArg2, TArg3>(Func<TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>, Func<IAsyncResult, TResult>, TArg1, TArg2, TArg3, Object, TaskCreationOptions)Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodStartNew(Func<TResult>)Creates and starts a Task<TResult>.
Public methodStartNew(Func<TResult>, CancellationToken)Creates and starts a Task<TResult>.
Public methodStartNew(Func<TResult>, TaskCreationOptions)Creates and starts a Task<TResult>.
Public methodStartNew(Func<Object, TResult>, Object)Creates and starts a Task<TResult>.
Public methodStartNew(Func<Object, TResult>, Object, CancellationToken)Creates and starts a Task<TResult>.
Public methodStartNew(Func<Object, TResult>, Object, TaskCreationOptions)Creates and starts a Task<TResult>.
Public methodStartNew(Func<TResult>, CancellationToken, TaskCreationOptions, TaskScheduler)Creates and starts a Task<TResult>.
Public methodStartNew(Func<Object, TResult>, Object, CancellationToken, TaskCreationOptions, TaskScheduler)Creates and starts a Task<TResult>.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The TaskFactory<TResult> class encodes some common Task<TResult> patterns into methods that pick up default settings, which are configurable through its constructors.

A default instance of TaskFactory<TResult> is available through the Factory property.

Silverlight

Supported in: 5

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

All public and protected members of TaskFactory<TResult> are thread-safe and may be used concurrently from multiple threads.

Community Additions

Show:
© 2014 Microsoft