view Implab/SyncContextPromise.cs @ 108:f3bdb7ba59b9 v2

sync
author cin
date Tue, 11 Nov 2014 18:37:35 +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);
        }
    }
}