Quant à l'usage de la Tâche.Start() , La Tâche.Run() et de la Tâche.Usine.StartNew()

Je viens de voir 3 routines concernant TPL utilisation qui font le même travail; voici le code:

public static void Main()
{
    Thread.CurrentThread.Name = "Main";

    //Create a task and supply a user delegate by using a lambda expression. 
    Task taskA = new Task( () => Console.WriteLine("Hello from taskA."));
    //Start the task.
    taskA.Start();

    //Output a message from the calling thread.
    Console.WriteLine("Hello from thread '{0}'.", 
                  Thread.CurrentThread.Name);
    taskA.Wait();
}

public static void Main()
{
    Thread.CurrentThread.Name = "Main";

    //Define and run the task.
    Task taskA = Task.Run( () => Console.WriteLine("Hello from taskA."));

    //Output a message from the calling thread.
    Console.WriteLine("Hello from thread '{0}'.", 
                      Thread.CurrentThread.Name);
    taskA.Wait();
}

public static void Main()
{
    Thread.CurrentThread.Name = "Main";

    //Better: Create and start the task in one operation. 
    Task taskA = Task.Factory.StartNew(() => Console.WriteLine("Hello from taskA."));

    //Output a message from the calling thread.
    Console.WriteLine("Hello from thread '{0}'.", 
                    Thread.CurrentThread.Name);

    taskA.Wait();                  
}

Je ne comprends pas pourquoi MS donne 3 façons différentes pour exécuter des travaux dans le TPL, car ils fonctionnent tous de la même: Task.Start(), Task.Run() et Task.Factory.StartNew().

Dites-moi,Task.Start(), Task.Run() et Task.Factory.StartNew() tous utilisé pour le même but, ou ont-ils une signification différente?

Quand doit-on utiliser Task.Start(), quand doit-on utiliser Task.Run() et quand doit-on utiliser Task.Factory.StartNew()?

S'il vous plaît aidez-moi à comprendre la réalité de leur utilisation par le scénario en détail avec des exemples, merci.

InformationsquelleAutor Mou | 2015-04-17