view Implab/SyncContextPromise.cs @ 75:4439140706d0 v2

major refactoring, added tasks support
author cin
date Wed, 10 Sep 2014 11:17:37 +0400
parents d67b95eddaf4
children 279e226dffdd
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, bool cancellable)
            : base(parent, cancellable) {
            Safe.ArgumentNotNull(context, "context");
            m_context = context;
        }
        protected override void InvokeHandler(HandlerDescriptor handler) {
            m_context.Post(x => base.InvokeHandler(handler),null);
        }
    }
}