如何将多个参数传递给 C# 线程?任何示例将不胜感激。
最佳答案
假设你有一个方法:
void A(string a, int b) {}
这应该有效(.NET 2.0):
ThreadStart starter = delegate { A("word", 10); };
Thread thread = new Thread(starter);
thread.Start();
对于更高版本,以下(更短):
ThreadStart starter = () => A("word", 10);
Thread thread = new Thread(starter);
//or just...
//Thread thread = new Thread(() => A("word",10));
thread.start()
关于c# - 如何将多个参数传递给 C# 线程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2490219/