annotate Implab.Fx/ControlBoundPromise.cs @ 75:4439140706d0 v2

major refactoring, added tasks support
author cin
date Wed, 10 Sep 2014 11:17:37 +0400
parents d67b95eddaf4
children b4c4d65b7def
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
1 using System.Windows.Forms;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
2 using System;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
3
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
4
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
5 namespace Implab.Fx {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
6 public class ControlBoundPromise<T> : Promise<T> {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
7 readonly Control m_target;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
8
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
9 public ControlBoundPromise(Control target) {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
10 Safe.ArgumentNotNull(target, "target");
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
11
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
12 m_target = target;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
13 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
14
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
15 public ControlBoundPromise(Control target, IPromise parent, bool cancellable)
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
16 : base(parent, cancellable) {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
17 Safe.ArgumentNotNull(target, "target");
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
18
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
19 m_target = target;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
20 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
21
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
22 protected override void InvokeHandler(HandlerDescriptor handler) {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
23 if (m_target.InvokeRequired)
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
24 m_target.BeginInvoke(new Action<HandlerDescriptor>(base.InvokeHandler), handler);
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
25 else
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
26 base.InvokeHandler(handler);
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
27 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
28 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
29 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
30