| Zhou's profileSheva's TechSpacePhotosBlogLists | Help |
|
8/6/2007 Delegate.BeginInvoke vs ThreadPool.QueueUserWorkItemToday, I come across Chris Brumme's blog on TransparentProxy, I really enjoy his blog, in particular those dedicated to the inner-working of CLR, one of the surprising sentence I read from his TransparentProxy article is that: 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. I have to say I get pretty stunned when reading this, so I write a little piece of code to verify his allegation: using System; And the following output is what I get when running above programme: Delegate.BeinInvoke(): 591441 From the output, there is no brainer that Delegate.BeginInvoke is way much slower than the ThreadPool.QueueUserWorkItem call.
Comments (12)
Zhou Yong
has turned off comments on this page.
Trackbacks (1)The trackback URL for this entry is: http://shevaspace.spaces.live.com/blog/cns!FD9A0F1F8DD06954!580.trak Weblogs that reference this entry
|
|
|