什么QueueUserWorkItem()和的BeginInvoke()之间的差,对于不需要返回类型执行异步活动 [英] What's the difference between QueueUserWorkItem() and BeginInvoke(), for performing an asynchronous activity with no return types needed

查看:216
本文介绍了什么QueueUserWorkItem()和的BeginInvoke()之间的差,对于不需要返回类型执行异步活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我的BeginInvoke()/ EndInvoke会()问题继,是否有在性能/别的Delegate.BeginInvoke(间),并使用QueueUserWorkItem主要差异()异步调用的委托?

Following on from my BeginInvoke()/EndInvoke() question, are there major differences in performance/anything else between Delegate.BeginInvoke() and using QueueUserWorkItem() to invoke a delegate asynchronously?

推荐答案

http://blogs.msdn.com/cbrumme/archive/2003/07/14/51495.aspx

说:

一个令人吃惊的事实是,这是
  也就是为什么Delegate.BeginInvoke /
  EndInvoke会是如此缓慢相比,
  相当于技术如
  ThreadPool.QueueUserWorkItem(或
  UnsafeQueueUserWorkItem如果你
  了解安全含义
  并希望成为真正有效)。该
  codePATH为的BeginInvoke / EndInvoke会
  很快变成了共同的信息
  一般的处理code
  远程处理途径。

"One surprising fact is that this is also why Delegate.BeginInvoke / EndInvoke are so slow compared to equivalent techniques like ThreadPool.QueueUserWorkItem (or UnsafeQueueUserWorkItem if you understand the security implications and want to be really efficient). The codepath for BeginInvoke / EndInvoke quickly turns into the common Message processing code of the general remoting pathway."

这篇关于什么QueueUserWorkItem()和的BeginInvoke()之间的差,对于不需要返回类型执行异步活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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