Mercurial > pub > ImplabNet
annotate Implab/FuncChainTask.cs @ 212:a01d9df88d74 v2
Added class Trace<T> to manage channels for individual classes, if SomeClass
uses Trace<SomeClass> it sould be marked with TraceSourceAttribute
author | cin |
---|---|
date | Tue, 04 Apr 2017 12:04:05 +0300 |
parents | 40d7fed4a09e |
children | eee3e49dd1ff |
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); |
145 | 18 } catch (Exception err) { |
196
40d7fed4a09e
fixed promise chaining behavior, the error handler doesn't handle result or cancellation handlers exceptions these exceptions are propagated to the next handlers.
cin
parents:
187
diff
changeset
|
19 SetErrorInternal(err); |
145 | 20 } |
21 } | |
22 } | |
23 } | |
24 } |