c# 多线程界面卡顿_C#多线程解决程序卡顿问题

C#

C#开发

C#语言

C#多线程解决程序卡顿问题

描述:

在 C# 中,System.Threading.Thread 类用于线程的工作。它允许创建并访问多线程应用程序中的单个线程。进程中第一个被执行的线程称为主线程。

案例:

static void Main(string[] args)

{

int num = 100;

for (int i = 0; i < num; i++)

{

//无参的多线程

noParmaThread();

}

}

private static void StartThread()

{

Console.WriteLine("------开始了新线程------");

Thread.Sleep(2000);//wait

Console.WriteLine("------线程结束------");

}

///

///不需要传递参数

///

private static void noParmaThread()

{

ThreadStart threadStart = new ThreadStart(StartThread);

var thread = new Thread(threadStart);

thread.Start();//开始线程

}

内容来源于网络,如有侵权请联系客服删除

你可能感兴趣的:(c#,多线程界面卡顿)