145
|
1 using System;
|
|
2
|
|
3 namespace Implab {
|
|
4 public class FuncChainTask<TResult> : FuncChainTaskBase<TResult>, IDeferred {
|
|
5 readonly Func<IPromise<TResult>> m_task;
|
|
6
|
149
|
7 public FuncChainTask(Func<IPromise<TResult>> task, Func<Exception, IPromise<TResult>> error, Func<Exception, IPromise<TResult>> cancel, bool autoCancellable)
|
|
8 : base(error, cancel, autoCancellable) {
|
145
|
9 m_task = task;
|
|
10 }
|
|
11
|
|
12 public void Resolve() {
|
|
13 if (m_task != null && LockCancelation()) {
|
|
14 try {
|
149
|
15 var operation = m_task();
|
|
16 operation.On(SetResult, HandleErrorInternal, SetCancelled);
|
|
17 CancellationRequested(operation.Cancel);
|
145
|
18 } catch (Exception err) {
|
|
19 HandleErrorInternal(err);
|
|
20 }
|
|
21 }
|
|
22 }
|
|
23 }
|
|
24 } |