title: How can I assign a name to a task in TPL
body: <p>I'm going to use lots of tasks running on my application. Each bunch of tasks is running for some reason. I would like to name these tasks so when I watch the Parallel Tasks window, I could recognize them easily.</p>
  
  <p>With another point of view, consider I'm using tasks at the framework level to populate a list. A developer that use my framework is also using tasks for her job. If she looks at the Parallel Tasks Window she will find some tasks having no idea about. I want to name tasks so she can distinguish the framework tasks from her tasks.</p>
  
  <p>It would be very convenient if there was such API:</p>
  
  <pre><code>var task = new Task(action, "Growth calculation task")
  </code></pre>
  
  <p>or maybe:</p>
  
  <pre><code>var task = Task.Factory.StartNew(action, "Populating the datagrid")
  </code></pre>
  
  <p>or even while working with <code>Parallel.ForEach</code></p>
  
  <pre><code>Parallel.ForEach(list, action, "Salary Calculation Task"
  </code></pre>
  
  <p>Is it possible to name a task?</p>
  
  <p>Is it possible to give ‍‍‍<code>Parallel.ForEach</code> a naming structure (maybe using a lambda) so it creates tasks with that naming?</p>
  
  <p>Is there such API somewhere that I'm missing?</p>
  
  <hr>
  
  <p>I've also tried to use an inherited task to override it's ToString(). But unfortunately the Parallel Tasks window doesn't use ToString()!</p>
  
  <pre><code>class NamedTask : Task
  {
      private string TaskName { get; set; }
      public NamedTask(Action action, string taskName):base(action)
      {
          TaskName = taskName;
      }
  
      public override string ToString()
      {
          return TaskName;
      }
  }
  </code></pre>