view Implab/SyncContextPromise.cs @ 106:d4e38929ce36 v2

promises refactoring
author cin
date Mon, 10 Nov 2014 18:00:28 +0300
parents 279e226dffdd
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);
        }
    }
}