Mercurial > pub > ImplabNet
annotate Implab.Fx/ControlBoundPromise.cs @ 144:8c0b95069066 v2
DRAFT: refactoring
author | cin |
---|---|
date | Fri, 06 Mar 2015 15:45:26 +0300 |
parents | f75cfa58e3d4 |
children | 706fccb85524 |
rev | line source |
---|---|
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 | |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
106
diff
changeset
|
15 protected override void SignalSuccess(IDeferred<T> handler) { |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
106
diff
changeset
|
16 if (m_target.InvokeRequired) |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
106
diff
changeset
|
17 m_target.BeginInvoke(new Action<IDeferred<T>>(base.SignalSuccess), handler); |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
106
diff
changeset
|
18 else |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
106
diff
changeset
|
19 base.SignalSuccess(handler); |
72 | 20 } |
21 | |
138
f75cfa58e3d4
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents:
119
diff
changeset
|
22 protected override void SignalCancelled(IDeferred<T> handler, Exception reason) { |
72 | 23 if (m_target.InvokeRequired) |
138
f75cfa58e3d4
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents:
119
diff
changeset
|
24 m_target.BeginInvoke(new Action<IDeferred<T>,Exception>(base.SignalCancelled), handler, reason); |
72 | 25 else |
138
f75cfa58e3d4
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents:
119
diff
changeset
|
26 base.SignalCancelled(handler, reason); |
72 | 27 } |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
106
diff
changeset
|
28 |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
106
diff
changeset
|
29 protected override void SignalError(IDeferred<T> handler, Exception error) { |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
106
diff
changeset
|
30 if (m_target.InvokeRequired) |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
106
diff
changeset
|
31 m_target.BeginInvoke(new Action<IDeferred<T>,Exception>(base.SignalError), handler, error); |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
106
diff
changeset
|
32 else |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
106
diff
changeset
|
33 base.SignalError(handler, error); |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
106
diff
changeset
|
34 } |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
106
diff
changeset
|
35 |
72 | 36 } |
37 } | |
38 |