view Implab/SyncContextPromise.cs @ 196:40d7fed4a09e

fixed promise chaining behavior, the error handler doesn't handle result or cancellation handlers exceptions these exceptions are propagated to the next handlers.
author cin
date Mon, 29 Aug 2016 23:15:51 +0300
parents 97fbbf816844
children 3eb3255d8cc5
line wrap: on
line source

using System.Threading;
using System;

namespace Implab {
    public class SyncContextPromise<T> : Promise<T> {
        readonly SynchronizationContext m_context;

        public SyncContextPromise(SynchronizationContext context) {
            Safe.ArgumentNotNull(context, "context");
            m_context = context;
        }

        protected override void SignalHandler(HandlerDescriptor handler, int signal) {
            m_context.Post(x => base.SignalHandler(handler, signal), null);
        }
    }
}