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