view Implab.Fx/ControlBoundPromise.cs @ 110:1a8426e6e895 v2

added promise timeout helper
author cin
date Sun, 16 Nov 2014 02:49:12 +0300
parents d4e38929ce36
children 2573b562e328
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)
            : base(parent) {
            Safe.ArgumentNotNull(target, "target");

            m_target = target;
        }

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