view Implab.Fx/ControlBoundPromise.cs @ 97:b11c7e9d93bc v2

added enumerable interface to MTQueue
author cin
date Fri, 31 Oct 2014 17:34:54 +0300
parents d67b95eddaf4
children b4c4d65b7def
line wrap: on
line source

using System.Windows.Forms;
using System;


namespace Implab.Fx {
    public class ControlBoundPromise<T> : Promise<T> {
        readonly Control m_target;

        public ControlBoundPromise(Control target) {
            Safe.ArgumentNotNull(target, "target");

            m_target = target;
        }

        public ControlBoundPromise(Control target, IPromise parent, bool cancellable)
            : base(parent, cancellable) {
            Safe.ArgumentNotNull(target, "target");

            m_target = target;
        }

        protected override void InvokeHandler(HandlerDescriptor handler) {
            if (m_target.InvokeRequired)
                m_target.BeginInvoke(new Action<HandlerDescriptor>(base.InvokeHandler), handler);
            else
                base.InvokeHandler(handler);
        }
    }
}