开发者

Do both BeginInvoke and EndInvoke on delegates generate full fences?

Threading in C# by Joseph Albahari talks briefly about it, stating:

The following implicitly generate full fences:

  • C#'s lock statement (Monitor.Enter/Monitor.Exit)
  • All methods on the Interlocked class (we’ll cover these soon)
  • Asynchronous callbacks that use the thread pool — these include asynchronous delegates, APM callbacks, and Task continuations
  • Setting and waiting on a signaling construct
  • Anything that relies on signaling, such as starting or waiting on a Task

As "asynchronous delegates" is in the list, I'd assume that at least EndInvoke is fully fenced. But what about BeginInvoke? Unfortunately I couldn't F11 (= debug step) into the BeginInvoke code - is the source available somewhere? Although a link t开发者_开发百科o a definite answer would be even better.


MSDN says BeginInvoke is threadsafe: http://msdn.microsoft.com/en-us/library/0b1bf3y3.aspx

there are four methods on a control that are thread safe: Invoke, BeginInvoke, EndInvoke, and CreateGraphics if the handle for the control has already been created


The source code the entire framework is available from Microsoft at the Reference Source Website

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜