What's the difference between QueueUserWorkItem() and BeginInvoke(), for performing an asynchronous activity with no return types needed

前端 未结 6 1966
甜味超标
甜味超标 2020-12-01 01:23

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

6条回答
  •  旧巷少年郎
    2020-12-01 01:26

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

    says:

    "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."

提交回复
热议问题