view Implab/SyncContextPromise.cs @ 107:f5220e5472ef v2

minor fixes and optimizations
author cin
date Tue, 11 Nov 2014 04:14:21 +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);
        }
    }
}