///------------------------------------------------------------------------------------------------- /// <summary> /// When overridden in a derived class, dispatches a synchronous message to a synchronization /// context. /// </summary> /// <param name="d"> /// The <see cref="T:System.Threading.SendOrPostCallback" /> delegate to call. /// </param> /// <param name="state"> /// The object passed to the delegate. /// </param> ///------------------------------------------------------------------------------------------------- public override void Send(SendOrPostCallback d, object state) { Action continuation = () => { SetSynchronizationContext(this); ((Action)state)(); }; if (OldContext != null) { OldContext.Send(d, continuation); } else { base.Send(d, continuation); } }