using System.Threading; namespace Implab { public class SyncContextPromise : Promise { readonly SynchronizationContext m_context; public SyncContextPromise(SynchronizationContext context) { Safe.ArgumentNotNull(context, "context"); m_context = context; } protected override void SignalSuccess(IDeferred handler) { m_context.Post(x => base.SignalSuccess(handler), null); } protected override void SignalError(IDeferred handler, System.Exception error) { m_context.Post(x => base.SignalError(handler, error), null); } protected override void SignalCancelled(IDeferred handler) { m_context.Post(x => base.SignalCancelled(handler), null); } } }