这个问题在这里已有答案:
下面的代码演示了创建执行相同作业的线程的两种方法,但只有一种方法有效,而另一方则无效。从我看到的差异是变量的声明 - 有人可以帮助解释为什么这会导致Error: Cannot implicitly convert type 'void' to 'System.Threading.Thread'
?
public MainWindow()
{
InitializeComponent();
// Runs OK
new Thread(() => { MessageBox.Show("foo");}).Start();
// Error: Cannot implicitly convert type 'void' to 'System.Threading.Thread'
Thread t = new Thread(() => { MessageBox.Show("foo”); }).Start();
}