annotate Implab.Fx/ControlBoundPromise.cs @ 153:b933ec88446e v2

docs
author cin
date Fri, 12 Feb 2016 00:59:29 +0300
parents 706fccb85524
children 97fbbf816844
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
145
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
15 protected override void SignalSuccess(Promise<T>.HandlerDescriptor handler) {
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
16 if (m_target.InvokeRequired)
145
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
17 m_target.BeginInvoke(new Action<Promise<T>.HandlerDescriptor>(base.SignalSuccess), handler);
119
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
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
20 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
21
145
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
22 protected override void SignalCancelled(Promise<T>.HandlerDescriptor handler, Exception reason) {
72
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
23 if (m_target.InvokeRequired)
145
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
24 m_target.BeginInvoke(new Action<Promise<T>.HandlerDescriptor,Exception>(base.SignalCancelled), handler, reason);
72
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
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
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
27 }
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
28
145
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
29 protected override void SignalError(Promise<T>.HandlerDescriptor handler, Exception error) {
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
30 if (m_target.InvokeRequired)
145
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
31 m_target.BeginInvoke(new Action<Promise<T>.HandlerDescriptor,Exception>(base.SignalError), handler, error);
119
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
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
36 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
37 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
38