C#开启新线程

	       using System;
               using System.Threading;
                 public static void Main(string[] args){
			Thread t=new Thread(DownLoadFile_My);//创建了线程还未开启
			t.Start("http://abc/def/**.mp4");//用来给函数传递参数,开启线程
			Console.WriteLine("main()");
			Console.ReadKey();
		}
		
		//thread开启线程要求:该方法参数只能有一个,且是object类型
		static void DownLoadFile_My(object filePath){
			Console.WriteLine("开始下载:"+filePath);
			Thread.Sleep(2000);
			Console.WriteLine("下载完成!");
		}

猜你喜欢

转载自blog.csdn.net/weixin_42731241/article/details/82290030