title: Passing value to thread start method in c#, when thread is created in loop
body: <p>I am creating threads in loop and I need to pass the counter of loop (as it was when the thread was created) in thread start method.</p>
  
  <pre><code>for (int i = 0; i &lt; ListSize; i++)
  {
      thread = new Thread(() =&gt; 
          Helper.GetEndToEndRequestProcessTime(EmailList[i], reqResultData, i, ListSize));
      workerThreads.Add(thread);
      thread.Start();
  }
  </code></pre>
  
  <p>In above example <code>i</code> is the variable I as argument in <code>GetEndToEndRequestProcessTime()</code>. But the issue is when actually thread is starting value of <code>i</code> is changing and I am getting wrong result in <code>GetEndToEndRequestProcessTime()</code>.</p>
  
  <p>How can I make sure that at the time when thread starts the value passed to <code>GetEndToEndRequestProcessTime()</code> is same as supplied when thread was created.</p>