有什么新的Thread(无效目标())和新的线程之间的差值(新的ThreadStart(无效目标()))? [英] What is the difference between new Thread(void Target()) and new Thread(new ThreadStart(void Target()))?

查看:149
本文介绍了有什么新的Thread(无效目标())和新的线程之间的差值(新的ThreadStart(无效目标()))?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果这已被问过,但我想在以下两种用法之间区别的回答言简意赅。 VS似乎接受他们两个是有效的代码。

Sorry if this has been asked before, but I would like a concise answer on the differences between the following two usages. VS seems to accept both of them as valid code.

private static void doSomeWork()
{
   //do some work
}

public someClass()
{
   //Thread thread = new Thread(doSomeWork);
   //or
   //Thread thread = new Thread(new ThreadStart(doSomeWork));
}


推荐答案

唯一的区别是,该第一个不工作在C#1的C#2编译器和后,转换第一个到第二个。

The only difference is that the first one doesn't work in C# 1. The compiler of C# 2 and later, translates the first one into the second one.

方法组是隐式转换为委托类型与兼容签名。此功能称为(隐)方法组转换。有时你需要第二个引导重载,但这里并非如此。

Method groups are implicitly convertible to delegate types with a compatible signature. This feature is called "(Implicit) method group conversion". Sometimes you need the second one to guide overload resolution, but that's not the case here.

这篇关于有什么新的Thread(无效目标())和新的线程之间的差值(新的ThreadStart(无效目标()))?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆