title: About the Task.StartNew(Action<Object>, Object) method
body: <p>I'm learning the TPL on this page, and one code block confuses me a lot.</p>
  
  <p>I was reading this page: <a href="http://msdn.microsoft.com/en-us/library/dd537609%28v=vs.110%29.aspx" rel="nofollow">Task Parallelism (Task Parallel Library)</a></p>
  
  <p>in one section, it said that the following code is the right solution because a lambda in a loop can't get the value as it mutates after each iteration, but the final value. So you should wrap the "i" in a CustomData object. The code is below:</p>
  
  <pre><code>class CustomData
  {
     public long CreationTime;
     public int Name; 
     public int ThreadNum;
  }
  
  public class Example
  {
     public static void Main()
     {
        // Create the task object by using an Action(Of Object) to pass in custom data 
        // to the Task constructor. This is useful when you need to capture outer variables 
        // from within a loop. 
        Task[] taskArray = new Task[10];
        for (int i = 0; i &lt; taskArray.Length; i++)
        {
           taskArray[i] = Task.Factory.StartNew( (Object obj ) =&gt;
              {
                 CustomData data = obj as CustomData;
                 if (data == null) 
                    return;
  
                 data.ThreadNum = Thread.CurrentThread.ManagedThreadId;
                 Console.WriteLine("Task #{0} created at {1} on thread #{2}.", data.Name, data.CreationTime, data.ThreadNum);
              },
              new CustomData()
              {
                 Name = i,
                 CreationTime = DateTime.Now.Ticks
              });
        }
        Task.WaitAll(taskArray);     
     }
  }
  </code></pre>
  
  <p>The code is rather straightforward and easy to understand but here comes my problem:</p>
  
  <p>in the Task.Factory.StartNew() method, the author uses one of its overload form:</p>
  
  <pre><code>Task.StartNew(Action&lt;Object&gt;, Object)
  </code></pre>
  
  <p>I am so curious to know <strong>where does the "obj" come from? How does it have 3 properties</strong>: Name, CreationTime and ThreadNum. </p>
  
  <p>I searched over MSDN found no useful detail but this: "An object containing data to be used by the action delegate." <a href="http://msdn.microsoft.com/en-us/library/dd321456%28v=vs.110%29.aspx" rel="nofollow">MSDN</a> It really doesn't explain anything. </p>
  
  <p>Could anyone explain it?</p>