using System; namespace Implab { public class ActionChainTask : ActionChainTaskBase, IDeferred { readonly Func m_task; /// /// Initializes a new instance of the class. /// /// The operation which will be performed when the is called. /// The error handler which will invoke when the is called or when the task fails with an error. /// The cancellation handler. /// If set to true will automatically accept /// all cancel requests before the task is started with , /// after that all requests are directed to the task. public ActionChainTask(Func task, Func error, Func cancel, bool autoCancellable) : base(error,cancel, autoCancellable) { m_task = task; } public void Resolve() { if (m_task != null && LockCancelation()) { try { var p = m_task(); p.On(SetResult, HandleErrorInternal, SetCancelled); CancellationRequested(p.Cancel); } catch(Exception err) { HandleErrorInternal(err); } } } } }