static void Func3(object o) { ParametersClass p = (ParametersClass)o; for (int i = 0; i < 1000; i++) { Console.WriteLine("Func3: " + p.Name + " ----> " + p.City + " ----> " + i); } }
// more then one parameters of thread function static void Main5(string[] args) { Thread t1 = new Thread(new ParameterizedThreadStart(Func1)); Thread t2 = new Thread(Func2); Thread t3 = new Thread(new ParameterizedThreadStart(Func3)); ParametersClass paraObj = new ParametersClass(); t1.Start("aman"); t2.Start("Kayare"); // t3.Start(new { Name ="Arpit" , City="Mumbai" }); here anonymous class won't work because formal para is of object type //and we need to cast it into ParametersClass which cant be done with anonymous class t3.Start(paraObj); for (int i = 0; i < 1000; i++) { Console.WriteLine("Main: " + i); } Console.ReadLine(); }