对于在 C# 中创建和启动新线程,我们的行为如下:
using System.Threading;
Thread thread = new Thread(new ThreadStart(WorkThreadFunction));
thread.Start();
public void WorkThreadFunction()
{
//Stuff Here
}
但是带有参数的方法呢?
对于这些方法,下面的代码有错误。
using System.Threading;
int a = 5;
int b = 6;
Thread thread = new Thread(new ThreadStart(WorkThreadFunction(a, b)));
thread.Start();
public void WorkThreadFunction(int a, int b)
{
//Stuff Here
}
错误 :
预期方法名称
我需要将这些参数传递给该方法!
解决办法是什么?
提前致谢