How does C # start a thread through the thread class
This article mainly introduces how C # starts threads through the thread class, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article.
Start a thread through the thread class
Using System; using System.Threading; public static void Main (string [] args) {Thread t=new Thread (DownLoadFile_My); / / created the thread without opening t.Start ("http://abc/def/**.mp4");// is used to pass parameters to the function, open the thread Console.WriteLine (" main () "); Console.ReadKey () } / / thread start thread requirement: there can be only one parameter for this method, and it is object type static void DownLoadFile_My (object filePath) {Console.WriteLine ("start download:" + filePath); Thread.Sleep (2000); Console.WriteLine ("download complete!") ;}
Running result:
Thank you for reading this article carefully. I hope the article "how to start threads through the thread class" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!