PromiseReaction`1.cs
24 lines
| 649 B
| text/x-csharp
|
CSharpLexer
/ Implab / PromiseReaction`1.cs
cin
|
r246 | using System; | |
namespace Implab { | |||
public class PromiseReaction<T> : IResolvable<T> { | |||
IDispatcher m_dispatcher; | |||
Action<T> m_onFulfilledJob; | |||
Action<Exception> m_onRejectedJob; | |||
public void Reject(Exception error) { | |||
if (m_dispatcher != null) | |||
m_dispatcher.Enqueue(() => m_onRejectedJob(error)); | |||
else | |||
m_onRejectedJob(error); | |||
} | |||
public void Resolve(T result) { | |||
if (m_dispatcher != null) | |||
m_dispatcher.Enqueue(() => m_onFulfilledJob(result)); | |||
else | |||
m_onFulfilledJob(result); | |||
} | |||
} | |||
} |