Java的可运行的C#版本? (代表?) [英] C# version of Java Runnable? (delegate?)
问题描述
我不能于是找到直接回答这个问题呢。是否与无效(无效)
签名的预定义的委托?
I could not find a direct answer to this question yet in SO. Is there a predefined delegate with void (void)
signature?
推荐答案
行动有你要找的签名。但是,这并不意味着同样的事情Runnable的作用:Runnable的通常表示run()方法的目的是要在一个线程中运行,而动作不作任何指示。对于你想要的ThreadStart ,它具有相同的签名,并且确实在这指示。
Action has the signature you're looking for. However, it doesn't mean the same thing as Runnable does: Runnable generally indicates that the run() method is intended to be run on a Thread, while Action makes no indication. For that you'd want ThreadStart, which has the same signature, and does make that indication.
如果你需要的是不带任何参数的委托,动作
是你要什么。如果你正在处理的线程,并需要指明start方法,使用的ThreadStart
。
If all you need is a delegate with no parameters, Action
is what you want. If you're dealing with threads and need to indicate the start method, use ThreadStart
.
这篇关于Java的可运行的C#版本? (代表?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!