diff Implab.Fx/ControlBoundPromise.cs @ 119:2573b562e328 v2

Promises rewritten, added improved version of AsyncQueue
author cin
date Sun, 11 Jan 2015 19:13:02 +0300
parents d4e38929ce36
children f75cfa58e3d4
line wrap: on
line diff
--- a/Implab.Fx/ControlBoundPromise.cs	Sun Dec 28 16:09:03 2014 +0300
+++ b/Implab.Fx/ControlBoundPromise.cs	Sun Jan 11 19:13:02 2015 +0300
@@ -12,19 +12,27 @@
             m_target = target;
         }
 
-        public ControlBoundPromise(Control target, IPromise parent)
-            : base(parent) {
-            Safe.ArgumentNotNull(target, "target");
-
-            m_target = target;
+        protected override void SignalSuccess(IDeferred<T> handler) {
+            if (m_target.InvokeRequired)
+                m_target.BeginInvoke(new Action<IDeferred<T>>(base.SignalSuccess), handler);
+            else
+                base.SignalSuccess(handler);
         }
 
-        protected override void InvokeHandler(AbstractHandler handler) {
+        protected override void SignalCancelled(IDeferred<T> handler) {
             if (m_target.InvokeRequired)
-                m_target.BeginInvoke(new Action<AbstractHandler>(base.InvokeHandler), handler);
+                m_target.BeginInvoke(new Action<IDeferred<T>>(base.SignalCancelled), handler);
             else
-                base.InvokeHandler(handler);
+                base.SignalCancelled(handler);
         }
+
+        protected override void SignalError(IDeferred<T> handler, Exception error) {
+            if (m_target.InvokeRequired)
+                m_target.BeginInvoke(new Action<IDeferred<T>,Exception>(base.SignalError), handler, error);
+            else
+                base.SignalError(handler, error);
+        }
+
     }
 }