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