C# 多線程傳遞多個參數
阿新 • • 發佈:2017-10-30
ole using msd 線程 logs pretty thp [] param
http://www.cnblogs.com/lvdongjie/p/5416883.html
3. 方式三:采用lambda表達式
對於lambda表達式不熟悉的可以查看微軟MSDN上的說明文檔。此處假設你熟悉。因為在大多數使用委托的時候我們一般也可以用lambda表達式的。
View Codeusing System; using System.Threading; namespace ThreadWithParameters { class Program { static void Main(string[] args) { string hello = "hello world"; //如果寫成Thread thread = new Thread(ThreadMainWithParameters(hello));這種形式,編譯時就會報錯 Thread thread = new Thread(() => ThreadMainWithParameters(hello)); thread.Start(); Console.Read(); } static void ThreadMainWithParameters(string str) { Console.WriteLine("Running in a thread,received: {0}", str); } } }
C# 多線程傳遞多個參數