##// END OF EJS Templates
Added awaiters to promises...
Added awaiters to promises Added static methods to Promise Resolve, Reject, All. Updated promise helpers

File last commit:

r248:5cb4826c2c2a v3
r248:5cb4826c2c2a v3
Show More
PromiseReaction.cs
41 lines | 1.4 KiB | text/x-csharp | CSharpLexer
/ Implab / PromiseReaction.cs
cin
missing files
r246 using System;
namespace Implab {
cin
Added awaiters to promises...
r248 /// <summary>
/// Базовыйй класс для создания обработчиков результов выполнения обещаний.
/// Данный объект связывает обработчик и обешание, при этом для выполнения
/// обработчика будет использоваться диспетчер.
/// </summary>
cin
working on promises
r247 abstract class PromiseReaction : IResolvable {
readonly IDispatcher m_dispatcher;
protected PromiseReaction(IDispatcher dispatcher) {
m_dispatcher = dispatcher;
}
cin
missing files
r246
cin
Added awaiters to promises...
r248 protected Action FulfilHandler { get; set; }
cin
missing files
r246
cin
Added awaiters to promises...
r248 protected Action<Exception> RejectHandler { get; set; }
cin
missing files
r246
public void Reject(Exception error) {
cin
Added awaiters to promises...
r248 if (RejectHandler == null)
cin
working on promises
r247 DefaultReject(error);
else if (m_dispatcher != null)
cin
Added awaiters to promises...
r248 m_dispatcher.Enqueue(RejectHandler, error);
cin
working on promises
r247 else
cin
Added awaiters to promises...
r248 RejectHandler(error);
cin
missing files
r246 }
public void Resolve() {
cin
Added awaiters to promises...
r248 if (FulfilHandler == null)
cin
working on promises
r247 DefaultResolve();
else if (m_dispatcher != null)
cin
Added awaiters to promises...
r248 m_dispatcher.Enqueue(FulfilHandler);
cin
working on promises
r247 else
cin
Added awaiters to promises...
r248 FulfilHandler();
cin
missing files
r246 }
cin
working on promises
r247
protected abstract void DefaultResolve();
protected abstract void DefaultReject(Exception reason);
cin
missing files
r246 }
}