Mercurial > pub > ImplabNet
comparison Implab/PromiseReaction`1.cs @ 246:5aa9cfbe56c3 v3
missing files
| author | cin |
|---|---|
| date | Fri, 26 Jan 2018 11:19:38 +0300 |
| parents | |
| children | fb70574741a1 |
comparison
equal
deleted
inserted
replaced
| 245:b904e0a3ba72 | 246:5aa9cfbe56c3 |
|---|---|
| 1 using System; | |
| 2 | |
| 3 namespace Implab { | |
| 4 public class PromiseReaction<T> : IResolvable<T> { | |
| 5 IDispatcher m_dispatcher; | |
| 6 | |
| 7 Action<T> m_onFulfilledJob; | |
| 8 | |
| 9 Action<Exception> m_onRejectedJob; | |
| 10 | |
| 11 public void Reject(Exception error) { | |
| 12 if (m_dispatcher != null) | |
| 13 m_dispatcher.Enqueue(() => m_onRejectedJob(error)); | |
| 14 else | |
| 15 m_onRejectedJob(error); | |
| 16 } | |
| 17 | |
| 18 public void Resolve(T result) { | |
| 19 if (m_dispatcher != null) | |
| 20 m_dispatcher.Enqueue(() => m_onFulfilledJob(result)); | |
| 21 else | |
| 22 m_onFulfilledJob(result); | |
| 23 } | |
| 24 } | |
| 25 } |
