@@ -51,7 +51,7 namespace Implab.Fx | |||
|
51 | 51 | { |
|
52 | 52 | var timer = new Timer(m_delay); |
|
53 | 53 | |
|
54 |
timer.AutoReset = |
|
|
54 | timer.AutoReset = false; | |
|
55 | 55 | timer.SynchronizingObject = m_syncronizationObject; |
|
56 | 56 | timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); |
|
57 | 57 |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -151,27 +151,69 namespace Implab { | |||
|
151 | 151 |
|
|
152 | 152 | return this; |
|
153 | 153 | |
|
154 | AddHandler(new ResultHandlerInfo() { | |
|
155 | resultHandler = success, | |
|
156 | errorHandler = error | |
|
157 | }); | |
|
154 | var medium = new Promise<T>(); | |
|
155 | ||
|
156 | var handlerInfo = new ResultHandlerInfo(); | |
|
158 | 157 | |
|
159 | return this; | |
|
158 | if (success != null) | |
|
159 | handlerInfo.resultHandler = x => { | |
|
160 | try { | |
|
161 | success(x); | |
|
162 | medium.Resolve(x); | |
|
163 | } catch (Exception e) { | |
|
164 | medium.Reject(e); | |
|
165 | } | |
|
166 | }; | |
|
167 | else | |
|
168 | handlerInfo.resultHandler = x => medium.Resolve(x); | |
|
169 | ||
|
170 | if (error != null) | |
|
171 | handlerInfo.errorHandler = x => { | |
|
172 | try { | |
|
173 | error(x); | |
|
174 | } catch { } | |
|
175 | medium.Reject(x); | |
|
176 | }; | |
|
177 | else | |
|
178 | handlerInfo.errorHandler = x => medium.Reject(x); | |
|
179 | ||
|
180 | AddHandler(handlerInfo); | |
|
181 | ||
|
182 | return medium; | |
|
160 | 183 | } |
|
161 | 184 | |
|
162 | 185 |
|
|
163 | 186 |
|
|
164 | 187 | } |
|
165 | 188 | |
|
189 | public Promise<T> Error(ErrorHandler error) { | |
|
190 | return Then(null, error); | |
|
191 | } | |
|
192 | ||
|
166 | 193 |
|
|
167 | 194 |
|
|
168 | 195 | return this; |
|
196 | ||
|
197 | var medium = new Promise<T>(); | |
|
198 | ||
|
169 | 199 |
|
|
170 | resultHandler = x => handler(), | |
|
171 | errorHandler = x => handler() | |
|
200 | resultHandler = x => { | |
|
201 | try { | |
|
202 | handler(); | |
|
203 | medium.Resolve(x); | |
|
204 | } catch (Exception e) { | |
|
205 | medium.Reject(e); | |
|
206 | } | |
|
207 | }, | |
|
208 | errorHandler = x => { | |
|
209 | try { | |
|
210 | handler(); | |
|
211 | } catch { } | |
|
212 | medium.Reject(x); | |
|
213 | } | |
|
172 | 214 | }); |
|
173 | 215 | |
|
174 | return this; | |
|
216 | return medium; | |
|
175 | 217 | } |
|
176 | 218 | |
|
177 | 219 |
|
General Comments 0
You need to be logged in to leave comments.
Login now