72
|
1 using System.Windows.Forms;
|
|
2 using System;
|
|
3
|
|
4
|
|
5 namespace Implab.Fx {
|
|
6 public class ControlBoundPromise<T> : Promise<T> {
|
|
7 readonly Control m_target;
|
|
8
|
|
9 public ControlBoundPromise(Control target) {
|
|
10 Safe.ArgumentNotNull(target, "target");
|
|
11
|
|
12 m_target = target;
|
|
13 }
|
|
14
|
|
15 public ControlBoundPromise(Control target, IPromise parent, bool cancellable)
|
|
16 : base(parent, cancellable) {
|
|
17 Safe.ArgumentNotNull(target, "target");
|
|
18
|
|
19 m_target = target;
|
|
20 }
|
|
21
|
|
22 protected override void InvokeHandler(HandlerDescriptor handler) {
|
|
23 if (m_target.InvokeRequired)
|
|
24 m_target.BeginInvoke(new Action<HandlerDescriptor>(base.InvokeHandler), handler);
|
|
25 else
|
|
26 base.InvokeHandler(handler);
|
|
27 }
|
|
28 }
|
|
29 }
|
|
30
|