FuncTask.cs
23 lines
| 632 B
| text/x-csharp
|
CSharpLexer
/ Implab / FuncTask.cs
|
|
r144 | using System; | ||
| using System.Threading; | ||||
| namespace Implab { | ||||
| public class FuncTask<T> : FuncTaskBase<T>, IDeferred { | ||||
| readonly Func<T> m_task; | ||||
|
|
r149 | public FuncTask(Func<T> task, Func<Exception, T> error, Func<Exception, T> cancel, bool autoCancellable) : base(error, cancel, autoCancellable) { | ||
|
|
r144 | m_task = task; | ||
| } | ||||
| public void Resolve() { | ||||
| if (m_task != null && LockCancelation()) { | ||||
| try { | ||||
| SetResult(m_task()); | ||||
| } catch(Exception err) { | ||||
|
|
r196 | SetErrorInternal(err); | ||
|
|
r144 | } | ||
| } | ||||
| } | ||||
| } | ||||
| } | ||||
