Get the App
SLTechnology News&Howtos  ›  Development  › 

How does C # start a thread through the thread class

Shulou Source: shulou.com Published: 2022-06-01 02:09:51 09月21日 Update

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!

Tags: Threads articles clips parameters values interests functions at the same time methods more friends knowledge types results ribbons industries information channels channels references Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL vpn Shulou Technology Huawei Docker