Mercurial > pub > ImplabNet
annotate Implab/FuncChainTask.cs @ 189:b60643b47078 ref20160224
Закрыть ветку ref20160224
author | cin |
---|---|
date | Fri, 22 Apr 2016 13:07:41 +0300 |
parents | dd4a3590f9c6 |
children | 40d7fed4a09e |
rev | line source |
---|---|
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(); |
187
dd4a3590f9c6
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler
cin
parents:
149
diff
changeset
|
16 operation.On(SetResult, HandleErrorInternal, HandleCancelInternal); |
149 | 17 CancellationRequested(operation.Cancel); |
187
dd4a3590f9c6
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler
cin
parents:
149
diff
changeset
|
18 } catch (OperationCanceledException reason) { |
dd4a3590f9c6
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler
cin
parents:
149
diff
changeset
|
19 HandleCancelInternal(reason); |
145 | 20 } catch (Exception err) { |
21 HandleErrorInternal(err); | |
22 } | |
23 } | |
24 } | |
25 } | |
26 } |