FuncChainTask.cs
23 lines
| 866 B
| text/x-csharp
|
CSharpLexer
/ Implab / FuncChainTask.cs
cin
|
r145 | using System; | |
namespace Implab { | |||
cin
|
r244 | public class FuncChainTask<TResult> : FuncChainTaskBase<TResult>, IResolvable { | |
cin
|
r145 | 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
|
r145 | } catch (Exception err) { | |
cin
|
r196 | SetErrorInternal(err); | |
cin
|
r145 | } | |
} | |||
} | |||
} | |||
} |