In earlier versions 1.1, it would be a bit difficult to input parameters to the new thread. In 2.0, because of the addition of the "ParameterizedThreadStart delegate, it simplifies the input of parameters.
Static void Main (string [] args)
{
Program instance = new Program ();
Thread threadSend = new Thread (new ParameterizedThreadStart (threadProc); // use ParameterizedThreadStart to delegate
String strParam = "this is the parameter I want to input ";
ThreadSend. Start (strParam); // input parameters here
}
Public static void threadProc (object param)
{
Console. WriteLine (param. ToString ());
// Do something
}
Pubulic static void threadProc (object param) // The parameter in the function declaration must be an object; otherwise, an error is returned.
If you want to input multiple parameters at a time, you can use object [] for encapsulation.