ActionTask.cs
24 lines
| 738 B
| text/x-csharp
|
CSharpLexer
/ Implab / ActionTask.cs
cin
|
r145 | using System; | ||
namespace Implab { | ||||
public class ActionTask : ActionTaskBase, IDeferred { | ||||
readonly Action m_task; | ||||
cin
|
r149 | public ActionTask(Action task, Action<Exception> error, Action<Exception> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) { | ||
cin
|
r145 | m_task = task; | ||
} | ||||
public void Resolve() { | ||||
if (m_task != null && LockCancelation()) { | ||||
try { | ||||
m_task(); | ||||
SetResult(); | ||||
cin
|
r187 | } catch(OperationCanceledException reason) { | ||
HandleCancelInternal(reason); | ||||
cin
|
r145 | } catch(Exception err) { | ||
HandleErrorInternal(err); | ||||
} | ||||
} | ||||
} | ||||
} | ||||
} | ||||