view Implab/SyncContextPromise.cs @ 113:468d156e434e v2-1

working on linked list
author cin
date Wed, 10 Dec 2014 01:29:53 +0100
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);
        }
    }
}