Task.Start Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Starts the Task, scheduling it for execution to the current TaskScheduler.

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

public void Start()

Exception Condition

The Task instance has been disposed.


The Task is not in a valid state to be started. It may have already been started, executed, or canceled, or it may have been created in a manner that doesn't support direct scheduling.

A task may be started and run only once. Any attempts to schedule a task a second time will result in an exception.

The Start is used to execute a task that has been created by calling one of the Task constructors. Typically, you do this when you need to separate the task's creation from its execution, such as when you conditionally execute tasks that you've created. For the more common case in which you don't need to separate task instantiation from execution, we recommend that you call an overload of the Task.Run or TaskFactory.StartNew method.

For information on handling exceptions thrown by task operations, see Exception Handling (Task Parallel Library).

The following example calls the Task(Action) constructor to instantiate a new Task object that displays its task ID and managed thread ID and then executes a loop. It then calls the Start method to execute the task. Since this is a console app, the call to the Wait method is necessary to prevent the app from terminating before the task finishes execution.

using System;
using System.Threading;
using System.Threading.Tasks;

public class Example
   public static void Main()
      var t = new Task( () => { Console.WriteLine("Task {0} running on thread {1}",
                                                  Task.CurrentId, Thread.CurrentThread.ManagedThreadId);
                                for (int ctr = 1; ctr <= 10; ctr++)
                                   Console.WriteLine("   Iteration {0}", ctr); } 
// The example displays output like the following:
//     Task 1 running on thread 3
//        Iteration 1
//        Iteration 2
//        Iteration 3
//        Iteration 4
//        Iteration 5
//        Iteration 6
//        Iteration 7
//        Iteration 8
//        Iteration 9
//        Iteration 10

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Available since 5.0
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top