title: Visual C++ (CLI) Threading
body: <p>I am using Visual C++ 2008 with CLI. I have a form with a textbox and a button, once i press the button i want the following code to output as follows:</p>
  
  <pre><code>private:
  
  System::Void button_Click(System::Object^  sender, System::EventArgs^  e) {
      Thread ^thr1 = gcnew Thread(gcnew ThreadStart(&amp;Form1::calculate("t1")));
      Thread ^thr2 = gcnew Thread(gcnew ThreadStart(&amp;Form1::calculate("t2")));
      thr1-&gt;Start();
      thr2-&gt;Start();
   }
  
  void calculate(String^ val) {
      int j;
  for(j=0; j&lt;10; j++)
      _txt-&gt;AppendText(val  + Convert::ToString(j) + "\n");
  }
  </code></pre>
  
  <p>Desired output:</p>
  
  <pre><code>t1 0
  t2 0
  t1 1
  t2 1
  </code></pre>
  
  <p>etc...</p>
  
  <p>My code above does not work. Stating that i the delegate requires two inputs at the gcnew Thead line. What am i doing wrong? Also is there a better way to achieve this?</p>