Mercurial > pub > ImplabNet
comparison Implab/Promise.cs @ 27:a236cd1f0477
fixes
author | cin |
---|---|
date | Mon, 03 Mar 2014 08:59:03 +0400 |
parents | f0bf98e4d22c |
children | 81708975d6f7 |
comparison
equal
deleted
inserted
replaced
26:f0bf98e4d22c | 27:a236cd1f0477 |
---|---|
314 return this; | 314 return this; |
315 | 315 |
316 var medium = new Promise<T>(this, true); | 316 var medium = new Promise<T>(this, true); |
317 | 317 |
318 AddHandler( | 318 AddHandler( |
319 null, | 319 x => medium.Resolve(x), |
320 e => { | 320 e => { |
321 try { | 321 try { |
322 medium.Resolve(handler(e)); | 322 medium.Resolve(handler(e)); |
323 } catch (Exception e2) { | 323 } catch (Exception e2) { |
324 medium.Reject(e2); | 324 medium.Reject(e2); |
539 | 539 |
540 if (queued && IsResolved && m_handlers.TryDequeue(out handler)) | 540 if (queued && IsResolved && m_handlers.TryDequeue(out handler)) |
541 // if the promise have been resolved while we was adding handler to the queue | 541 // if the promise have been resolved while we was adding handler to the queue |
542 // we can't guarantee that someone is still processing it | 542 // we can't guarantee that someone is still processing it |
543 // therefore we will fetch a handler from the queue and execute it | 543 // therefore we will fetch a handler from the queue and execute it |
544 // note that fetched handler may be not the one we have added | 544 // note that fetched handler may be not the one that we have added |
545 // even we can fetch no handlers at all :) | |
545 InvokeHandler(handler); | 546 InvokeHandler(handler); |
546 | 547 } |
547 } | 548 |
548 | 549 protected virtual void InvokeHandler(HandlerDescriptor handler) { |
549 void InvokeHandler(HandlerDescriptor handler) { | |
550 switch (m_state) { | 550 switch (m_state) { |
551 case SucceededState: | 551 case SucceededState: |
552 handler.Resolve(m_result); | 552 handler.Resolve(m_result); |
553 break; | 553 break; |
554 case RejectedState: | 554 case RejectedState: |