FuncChainTask.cs
25 lines
| 979 B
| text/x-csharp
|
CSharpLexer
/ Implab / FuncChainTask.cs
cin
|
r145 | using System; | |
namespace Implab { | |||
public class FuncChainTask<TResult> : FuncChainTaskBase<TResult>, IDeferred { | |||
readonly Func<IPromise<TResult>> m_task; | |||
cin
|
r149 | public FuncChainTask(Func<IPromise<TResult>> task, Func<Exception, IPromise<TResult>> error, Func<Exception, IPromise<TResult>> cancel, bool autoCancellable) | |
: base(error, cancel, autoCancellable) { | |||
cin
|
r145 | m_task = task; | |
} | |||
public void Resolve() { | |||
if (m_task != null && LockCancelation()) { | |||
try { | |||
cin
|
r149 | var operation = m_task(); | |
cin
|
r187 | operation.On(SetResult, HandleErrorInternal, HandleCancelInternal); | |
cin
|
r149 | CancellationRequested(operation.Cancel); | |
cin
|
r187 | } catch (OperationCanceledException reason) { | |
HandleCancelInternal(reason); | |||
cin
|
r145 | } catch (Exception err) { | |
HandleErrorInternal(err); | |||
} | |||
} | |||
} | |||
} | |||
} |