view Implab/SyncContextPromise.cs @ 99:8ddf1648eca4 v2

fixed TransientPromiseException handling
author cin
date Wed, 05 Nov 2014 02:31:35 +0300
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);
        }
    }
}