comparison Implab/SuccessPromiseT.cs @ 203:4d9830a9bbb8 v2

Added 'Fail' method to RunnableComponent which allows component to move from Running to Failed state. Added PollingComponent a timer based runnable component More tests Added FailPromise a thin class to wrap exceptions Fixed error handling in SuccessPromise classes.
author cin
date Tue, 18 Oct 2016 17:49:54 +0300
parents 706fccb85524
children cbe10ac0731e
comparison
equal deleted inserted replaced
202:2651cb9a4250 203:4d9830a9bbb8
10 10
11 public IPromise<T> On(Action<T> success, Action<Exception> error, Action<Exception> cancel) { 11 public IPromise<T> On(Action<T> success, Action<Exception> error, Action<Exception> cancel) {
12 if (success != null) { 12 if (success != null) {
13 try { 13 try {
14 success(m_value); 14 success(m_value);
15 } catch(Exception err) { 15 // Analysis disable once EmptyGeneralCatchClause
16 if (error != null) { 16 } catch {
17 try {
18 error(err);
19 // Analysis disable once EmptyGeneralCatchClause
20 } catch {
21 }
22 }
23 } 17 }
24 } 18 }
25 return this; 19 return this;
26 } 20 }
27 21
28 public IPromise<T> On(Action<T> success, Action<Exception> error) { 22 public IPromise<T> On(Action<T> success, Action<Exception> error) {
29 if (success != null) { 23 if (success != null) {
30 try { 24 try {
31 success(m_value); 25 success(m_value);
32 } catch(Exception err) { 26 // Analysis disable once EmptyGeneralCatchClause
33 if (error != null) { 27 } catch {
34 try {
35 error(err);
36 // Analysis disable once EmptyGeneralCatchClause
37 } catch {
38 }
39 }
40 } 28 }
41 } 29 }
42 return this; 30 return this;
43 } 31 }
44 32
63 51
64 public IPromise<T> On(Action success, Action<Exception> error, Action<Exception> cancel) { 52 public IPromise<T> On(Action success, Action<Exception> error, Action<Exception> cancel) {
65 if (success != null) { 53 if (success != null) {
66 try { 54 try {
67 success(); 55 success();
68 } catch(Exception err) { 56 // Analysis disable once EmptyGeneralCatchClause
69 if (error != null) { 57 } catch {
70 try {
71 error(err);
72 // Analysis disable once EmptyGeneralCatchClause
73 } catch {
74 }
75 }
76 } 58 }
77 } 59 }
78 return this; 60 return this;
79 } 61 }
80 62
81 public IPromise<T> On(Action success, Action<Exception> error) { 63 public IPromise<T> On(Action success, Action<Exception> error) {
82 if (success != null) { 64 if (success != null) {
83 try { 65 try {
84 success(); 66 success();
85 } catch(Exception err) { 67 // Analysis disable once EmptyGeneralCatchClause
86 if (error != null) { 68 } catch {
87 try {
88 error(err);
89 // Analysis disable once EmptyGeneralCatchClause
90 } catch {
91 }
92 }
93 } 69 }
94 } 70 }
95 return this; 71 return this;
96 } 72 }
97 73