المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Simple MultiThread question



C# Programming
01-28-2012, 12:30 PM
Hi I would like to use argument in ThreadStart Delegate but I have problem with syntax. here the code example

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace mtquestion { class Program { static void Main(string[] args) { Thread T1 = new Thread(new ThreadStart(C(15,25))); Thread T2 = new Thread(new ThreadStart(C(15, 29))); Thread T3 = new Thread(new ThreadStart(C(18, 25))); T1.Start(); T2.Start(); T3.Start(); object locker = new object(); lock (locker) T1.Join(); T2.Join(); T3.Join(); lock (locker) Console.Write("c"); } public static void C(double a, double b) { Console.WriteLine(a*b);} } }
the syntax
Thread T1 = new Thread(new ThreadStart(C(15,25)));
return the following error"method name expected"
How can I pass arguments?
Thanks for your time