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