diff Implab/ActionChainTask.cs @ 149:eb793fbbe4ea v2

fixed promises cancellation
author cin
date Wed, 06 May 2015 17:11:27 +0300
parents 706fccb85524
children 822aab37b107
line wrap: on
line diff
--- a/Implab/ActionChainTask.cs	Wed Apr 15 07:30:20 2015 +0300
+++ b/Implab/ActionChainTask.cs	Wed May 06 17:11:27 2015 +0300
@@ -4,14 +4,16 @@
     public class ActionChainTask : ActionChainTaskBase, IDeferred {
         readonly Func<IPromise> m_task;
 
-        public ActionChainTask(Func<IPromise> task, Func<Exception, IPromise> error, Func<Exception, IPromise> cancel) : base(error,cancel) {
+        public ActionChainTask(Func<IPromise> task, Func<Exception, IPromise> error, Func<Exception, IPromise> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) {
             m_task = task;
         }
 
         public void Resolve() {
             if (m_task != null && LockCancelation()) {
                 try {
-                    Observe(m_task());
+                    var p = m_task();
+                    p.On(SetResult, HandleErrorInternal, SetCancelled);
+                    CancellationRequested(p.Cancel);
                 } catch(Exception err) {
                     HandleErrorInternal(err);
                 }