view Implab/SyncContextPromise.cs @ 115:ffd3702968c7 v2

fixed JSON writer
author cin
date Sun, 21 Dec 2014 13:52:08 +0300
parents d4e38929ce36
children 2573b562e328
line wrap: on
line source

using System.Threading;

namespace Implab {
    public class SyncContextPromise<T> : Promise<T> {
        readonly SynchronizationContext m_context;

        public SyncContextPromise(SynchronizationContext context) {
            Safe.ArgumentNotNull(context, "context");
            m_context = context;
        }

        public SyncContextPromise(SynchronizationContext context, IPromise parent)
            : base(parent) {
            Safe.ArgumentNotNull(context, "context");
            m_context = context;
        }
        protected override void InvokeHandler(AbstractHandler handler) {
            m_context.Post(x => base.InvokeHandler(handler),null);
        }
    }
}