Mercurial > pub > ImplabNet
diff Implab/FuncTaskT.cs @ 192:f1da3afc3521 release v2.1
Слияние с v2
author | cin |
---|---|
date | Fri, 22 Apr 2016 13:10:34 +0300 |
parents | dd4a3590f9c6 |
children | 40d7fed4a09e |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab/FuncTaskT.cs Fri Apr 22 13:10:34 2016 +0300 @@ -0,0 +1,24 @@ +using System; + +namespace Implab { + public class FuncTask<TArg, TResult> : FuncTaskBase<TResult>, IDeferred<TArg> { + readonly Func<TArg, TResult> m_task; + + public FuncTask(Func<TArg, TResult> task, Func<Exception, TResult> error,Func<Exception, TResult> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) { + m_task = task; + } + + public void Resolve(TArg value) { + if (m_task != null && LockCancelation()) { + try { + SetResult(m_task(value)); + } catch(OperationCanceledException reason) { + HandleCancelInternal(reason); + } catch(Exception err) { + HandleErrorInternal(err); + } + } + } + } +} +