TaskFactory Class

Provides support for creating and scheduling Task objects.

System.Object
  System.Threading.Tasks.TaskFactory

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

'Declaration
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
	ExternalThreading := True)> _
Public Class TaskFactory

The TaskFactory type exposes the following members.

  NameDescription
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsTaskFactoryInitializes a TaskFactory instance with the default configuration.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsTaskFactory(CancellationToken)Initializes a TaskFactory instance with the specified configuration.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsTaskFactory(TaskScheduler)Initializes a TaskFactory instance with the specified configuration.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsTaskFactory(TaskCreationOptions, TaskContinuationOptions)Initializes a TaskFactory instance with the specified configuration.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsTaskFactory(CancellationToken, TaskCreationOptions, TaskContinuationOptions, TaskScheduler)Initializes a TaskFactory instance with the specified configuration.
Top

  NameDescription
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsCancellationTokenGets the default cancellation token for this task factory.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsContinuationOptionsGets the default task continuation options for this task factory.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsCreationOptionsGets the default task creation options for this task factory.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsSchedulerGets the default task scheduler for this task factory.
Top

  NameDescription
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Task(), Action(Of Task()))Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Task(), Action(Of Task()), CancellationToken)Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Task(), Action(Of Task()), TaskContinuationOptions)Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Task(), Action(Of Task()), CancellationToken, TaskContinuationOptions, TaskScheduler)Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Of TResult)(Task(), Func(Of Task(), TResult))Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Of TAntecedentResult)(Task(Of TAntecedentResult)(), Action(Of Task(Of TAntecedentResult)()))Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Of TResult)(Task(), Func(Of Task(), TResult), CancellationToken)Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Of TResult)(Task(), Func(Of Task(), TResult), TaskContinuationOptions)Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Of TAntecedentResult)(Task(Of TAntecedentResult)(), Action(Of Task(Of TAntecedentResult)()), CancellationToken)Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Of TAntecedentResult)(Task(Of TAntecedentResult)(), Action(Of Task(Of TAntecedentResult)()), TaskContinuationOptions)Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Of TResult)(Task(), Func(Of Task(), TResult), CancellationToken, TaskContinuationOptions, TaskScheduler)Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Of TAntecedentResult)(Task(Of TAntecedentResult)(), Action(Of Task(Of TAntecedentResult)()), CancellationToken, TaskContinuationOptions, TaskScheduler)Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Of TAntecedentResult, TResult)(Task(Of TAntecedentResult)(), Func(Of Task(Of TAntecedentResult)(), TResult))Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Of TAntecedentResult, TResult)(Task(Of TAntecedentResult)(), Func(Of Task(Of TAntecedentResult)(), TResult), CancellationToken)Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Of TAntecedentResult, TResult)(Task(Of TAntecedentResult)(), Func(Of Task(Of TAntecedentResult)(), TResult), TaskContinuationOptions)Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAll(Of TAntecedentResult, TResult)(Task(Of TAntecedentResult)(), Func(Of Task(Of TAntecedentResult)(), TResult), CancellationToken, TaskContinuationOptions, TaskScheduler)Creates a continuation task that starts when a set of specified tasks has completed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Task(), Action(Of Task))Creates a continuation Task that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Task(), Action(Of Task), CancellationToken)Creates a continuation Task that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Task(), Action(Of Task), TaskContinuationOptions)Creates a continuation Task that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Task(), Action(Of Task), CancellationToken, TaskContinuationOptions, TaskScheduler)Creates a continuation Task that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Of TResult)(Task(), Func(Of Task, TResult))Creates a continuation Task(Of TResult) that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Of TAntecedentResult)(Task(Of TAntecedentResult)(), Action(Of Task(Of TAntecedentResult)))Creates a continuation Task that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Of TResult)(Task(), Func(Of Task, TResult), CancellationToken)Creates a continuation Task(Of TResult) that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Of TResult)(Task(), Func(Of Task, TResult), TaskContinuationOptions)Creates a continuation Task(Of TResult) that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Of TAntecedentResult)(Task(Of TAntecedentResult)(), Action(Of Task(Of TAntecedentResult)), CancellationToken)Creates a continuation Task that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Of TAntecedentResult)(Task(Of TAntecedentResult)(), Action(Of Task(Of TAntecedentResult)), TaskContinuationOptions)Creates a continuation Task that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Of TResult)(Task(), Func(Of Task, TResult), CancellationToken, TaskContinuationOptions, TaskScheduler)Creates a continuation Task(Of TResult) that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Of TAntecedentResult)(Task(Of TAntecedentResult)(), Action(Of Task(Of TAntecedentResult)), CancellationToken, TaskContinuationOptions, TaskScheduler)Creates a continuation Task that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Of TAntecedentResult, TResult)(Task(Of TAntecedentResult)(), Func(Of Task(Of TAntecedentResult), TResult))Creates a continuation Task(Of TResult) that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Of TAntecedentResult, TResult)(Task(Of TAntecedentResult)(), Func(Of Task(Of TAntecedentResult), TResult), CancellationToken)Creates a continuation Task(Of TResult) that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Of TAntecedentResult, TResult)(Task(Of TAntecedentResult)(), Func(Of Task(Of TAntecedentResult), TResult), TaskContinuationOptions)Creates a continuation Task(Of TResult) that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContinueWhenAny(Of TAntecedentResult, TResult)(Task(Of TAntecedentResult)(), Func(Of Task(Of TAntecedentResult), TResult), CancellationToken, TaskContinuationOptions, TaskScheduler)Creates a continuation Task(Of TResult) that will be started upon the completion of any Task in the provided set.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(IAsyncResult, Action(Of IAsyncResult))Creates a Task that executes an end method action when a specified IAsyncResult completes.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Func(Of AsyncCallback, Object, IAsyncResult), Action(Of IAsyncResult), Object)Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(IAsyncResult, Action(Of IAsyncResult), TaskCreationOptions)Creates a Task that executes an end method action when a specified IAsyncResult completes.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Func(Of AsyncCallback, Object, IAsyncResult), Action(Of IAsyncResult), Object, TaskCreationOptions)Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(IAsyncResult, Action(Of IAsyncResult), TaskCreationOptions, TaskScheduler)Creates a Task that executes an end method action when a specified IAsyncResult completes.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TResult)(IAsyncResult, Func(Of IAsyncResult, TResult))Creates a Task(Of TResult) that executes an end method function when a specified IAsyncResult completes.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TResult)(Func(Of AsyncCallback, Object, IAsyncResult), Func(Of IAsyncResult, TResult), Object)Creates a Task(Of TResult) that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TResult)(IAsyncResult, Func(Of IAsyncResult, TResult), TaskCreationOptions)Creates a Task(Of TResult) that executes an end method function when a specified IAsyncResult completes.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TResult)(Func(Of AsyncCallback, Object, IAsyncResult), Func(Of IAsyncResult, TResult), Object, TaskCreationOptions)Creates a Task(Of TResult) that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TArg1)(Func(Of TArg1, AsyncCallback, Object, IAsyncResult), Action(Of IAsyncResult), TArg1, Object)Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TResult)(IAsyncResult, Func(Of IAsyncResult, TResult), TaskCreationOptions, TaskScheduler)Creates a Task(Of TResult) that executes an end method function when a specified IAsyncResult completes.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TArg1)(Func(Of TArg1, AsyncCallback, Object, IAsyncResult), Action(Of IAsyncResult), TArg1, Object, TaskCreationOptions)Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TArg1, TResult)(Func(Of TArg1, AsyncCallback, Object, IAsyncResult), Func(Of IAsyncResult, TResult), TArg1, Object)Creates a Task(Of TResult) that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TArg1, TResult)(Func(Of TArg1, AsyncCallback, Object, IAsyncResult), Func(Of IAsyncResult, TResult), TArg1, Object, TaskCreationOptions)Creates a Task(Of TResult) that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TArg1, TArg2)(Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), Action(Of IAsyncResult), TArg1, TArg2, Object)Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TArg1, TArg2)(Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), Action(Of IAsyncResult), TArg1, TArg2, Object, TaskCreationOptions)Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TArg1, TArg2, TResult)(Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), Func(Of IAsyncResult, TResult), TArg1, TArg2, Object)Creates a Task(Of TResult) that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TArg1, TArg2, TResult)(Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), Func(Of IAsyncResult, TResult), TArg1, TArg2, Object, TaskCreationOptions)Creates a Task(Of TResult) that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TArg1, TArg2, TArg3)(Func(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), Action(Of IAsyncResult), TArg1, TArg2, TArg3, Object)Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TArg1, TArg2, TArg3)(Func(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), Action(Of IAsyncResult), TArg1, TArg2, TArg3, Object, TaskCreationOptions)Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TArg1, TArg2, TArg3, TResult)(Func(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), Func(Of IAsyncResult, TResult), TArg1, TArg2, TArg3, Object)Creates a Task(Of TResult) that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFromAsync(Of TArg1, TArg2, TArg3, TResult)(Func(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), Func(Of IAsyncResult, TResult), TArg1, TArg2, TArg3, Object, TaskCreationOptions)Creates a Task(Of TResult) that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Action)Creates and starts a task.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Action, CancellationToken)Creates and starts a Task.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Action, TaskCreationOptions)Creates and starts a Task.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Action(Of Object), Object)Creates and starts a Task.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Action(Of Object), Object, CancellationToken)Creates and starts a Task.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Action(Of Object), Object, TaskCreationOptions)Creates and starts a Task.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Action, CancellationToken, TaskCreationOptions, TaskScheduler)Creates and starts a Task.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Action(Of Object), Object, CancellationToken, TaskCreationOptions, TaskScheduler)Creates and starts a Task.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Of TResult)(Func(Of TResult))Creates and starts a Task(Of TResult).
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Of TResult)(Func(Of TResult), CancellationToken)Creates and starts a Task(Of TResult).
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Of TResult)(Func(Of TResult), TaskCreationOptions)Creates and starts a Task(Of TResult).
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Of TResult)(Func(Of Object, TResult), Object)Creates and starts a Task(Of TResult).
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Of TResult)(Func(Of Object, TResult), Object, CancellationToken)Creates and starts a Task(Of TResult).
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Of TResult)(Func(Of Object, TResult), Object, TaskCreationOptions)Creates and starts a Task(Of TResult).
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Of TResult)(Func(Of TResult), CancellationToken, TaskCreationOptions, TaskScheduler)Creates and starts a Task(Of TResult).
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsStartNew(Of TResult)(Func(Of Object, TResult), Object, CancellationToken, TaskCreationOptions, TaskScheduler)Creates and starts a Task(Of TResult).
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The TaskFactory class encodes some common Task patterns into methods that pick up default settings, which are configurable through its constructors. A default instance of TaskFactory is available through the Task.Factory property.

NoteNote

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: Synchronization | ExternalThreading. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft