Mercurial > pub > ImplabNet
diff Implab/FuncTask.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/FuncTask.cs Fri Apr 22 13:10:34 2016 +0300 @@ -0,0 +1,25 @@ +using System; +using System.Threading; + +namespace Implab { + public class FuncTask<T> : FuncTaskBase<T>, IDeferred { + readonly Func<T> m_task; + + public FuncTask(Func<T> task, Func<Exception, T> error, Func<Exception, T> cancel, bool autoCancellable) : base(error, cancel, autoCancellable) { + m_task = task; + } + + public void Resolve() { + if (m_task != null && LockCancelation()) { + try { + SetResult(m_task()); + } catch(OperationCanceledException reason) { + HandleCancelInternal(reason); + } catch(Exception err) { + HandleErrorInternal(err); + } + } + } + } +} +