实例化线程 [英] Instantiating a thread

查看:150
本文介绍了实例化线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这对大多数人来说可能是令人眼花obvious乱的:叹息:

说我有一个线程

Ok, this might be blindingly obvious to most :sigh:

Say I have a thread

Thread myThread;

之间有什么区别,

What is the difference between,

Thread myThread = new Thread(Work.DoWork);

Thread myThread = new Thread(new ParameterizedThreadStart(Work.DoWork)); 



MSDN说, C#推断适当的委托创建语法:new ParameterizedThreadStart(Work.DoWork) .



MSDN says, C# infers the appropriate delegate creation syntax: new ParameterizedThreadStart(Work.DoWork). So does that mean the above 2 lines are identical?

推荐答案

那么这意味着以上两行是相同的吗?
So does that mean the above 2 lines are identical?



是的,完全是的意思.详细版本是在C#1.0中执行此操作的唯一方法,而在幕后它仍然是正在发生的事情-但由于委托实例化从上下文中是显而易见的,因此C#2和更高版本不需要除非存在某种歧义,否则您要实际指定它.



Yes, that''s exactly what it means. The verbose version was the only way to do it in C# 1.0, and under the hood it''s still what''s happening - but since the delegate instantiation is fairly obvious from the context, C# 2 and later don''t require you to actually specify it unless there''s some sort of ambiguity.


这篇关于实例化线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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