为什么要使用ThreadStart? [英] Why use ThreadStart?
本文介绍了为什么要使用ThreadStart?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以说明为什么我们使用ThreadStart吗?
Can somebody please clarify why we use ThreadStart?
new Thread (new ThreadStart (Update)).Start(); -Versus-
new Thread (Update).Start(); // Seems more straightforward
private void Update() { }
推荐答案
有人可以说明为什么我们使用ThreadStart吗?
Can somebody please clarify why we use ThreadStart?
您不必这样做.如果这样做,只有您可以说出原因...
You don't have to. If you do, only you can say why...
从C#2开始,方法组(即通过其名称对方法的引用)可以隐式转换为具有相同签名的委托.由于Thread
构造函数采用ThreadStart
,因此您可以将其传递给具有与ThreadStart
相同签名的方法组.
Since C# 2, method groups (i.e. references to a method via its name) are implicitly convertible to delegates with the same signature. Since the Thread
constructor takes a ThreadStart
, you can pass it a method group with the same signature as ThreadStart
.
这篇关于为什么要使用ThreadStart?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文