IPromise.cs
66 lines
| 2.8 KiB
| text/x-csharp
|
CSharpLexer
/ Implab / IPromise.cs
|
|
r7 | using System; | ||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
|
|
r66 | namespace Implab { | ||
| public interface IPromise: ICancellable { | ||||
|
|
r26 | |||
|
|
r66 | /// <summary> | ||
| /// Тип результата, получаемого через данное обещание. | ||||
| /// </summary> | ||||
| Type PromiseType { get; } | ||||
|
|
r25 | |||
|
|
r74 | /// <summary> | ||
|
|
r99 | /// Обещание является выполненым, либо успешно, либо с ошибкой, либо отменено. | ||
|
|
r74 | /// </summary> | ||
|
|
r66 | bool IsResolved { get; } | ||
|
|
r74 | /// <summary> | ||
| /// Обещание было отменено. | ||||
| /// </summary> | ||||
|
|
r66 | bool IsCancelled { get; } | ||
|
|
r25 | |||
|
|
r119 | /// <summary> | ||
|
|
r138 | /// Исключение возникшее в результате выполнения обещания, либо причина отмены. | ||
| /// </summary> | ||||
| Exception Error { get; } | ||||
| /// <summary> | ||||
|
|
r119 | /// Adds specified listeners to the current promise. | ||
|
|
r75 | /// </summary> | ||
|
|
r119 | /// <param name="success">The handler called on the successful promise completion.</param> | ||
| /// <param name="error">The handler is called if an error while completing the promise occurred.</param> | ||||
| /// <param name="cancel">The handler is called in case of promise cancellation.</param> | ||||
| /// <returns>The current promise.</returns> | ||||
|
|
r138 | IPromise On(Action success, Action<Exception> error, Action<Exception> cancel); | ||
|
|
r119 | IPromise On(Action success, Action<Exception> error); | ||
| IPromise On(Action success); | ||||
|
|
r75 | |||
|
|
r74 | /// <summary> | ||
|
|
r119 | /// Adds specified listeners to the current promise. | ||
| /// </summary> | ||||
| /// <param name="handler">The handler called on the specified events.</param> | ||||
| /// <param name = "events">The combination of flags denoting the events for which the | ||||
| /// handler shoud be called.</param> | ||||
| /// <returns>The current promise.</returns> | ||||
| IPromise On(Action handler, PromiseEventType events); | ||||
| /// <summary> | ||||
|
|
r74 | /// Преобразует результат обещания к заданному типу и возвращает новое обещание. | ||
| /// </summary> | ||||
|
|
r66 | IPromise<T> Cast<T>(); | ||
|
|
r26 | |||
|
|
r74 | /// <summary> | ||
| /// Синхронизирует текущий поток с обещанием. | ||||
| /// </summary> | ||||
|
|
r66 | void Join(); | ||
|
|
r74 | /// <summary> | ||
| /// Синхронизирует текущий поток с обещанием. | ||||
| /// </summary> | ||||
| /// <param name="timeout">Время ожидания, по его истечению возникнет исключение.</param> | ||||
| /// <exception cref="TimeoutException">Превышено время ожидания.</exception> | ||||
|
|
r66 | void Join(int timeout); | ||
|
|
r7 | |||
| } | ||||
| } | ||||
