diff Implab/Components/RunnableComponent.cs @ 186:75103928da09 ref20160224

working on cancelation and error handling
author cin
date Tue, 19 Apr 2016 00:50:14 +0300
parents 822aab37b107
children dd4a3590f9c6
line wrap: on
line diff
--- a/Implab/Components/RunnableComponent.cs	Mon Apr 18 16:41:17 2016 +0300
+++ b/Implab/Components/RunnableComponent.cs	Tue Apr 19 00:50:14 2016 +0300
@@ -139,14 +139,7 @@
                         throw new PromiseTransientException(e);
                     },
                     r => {
-                        lock(m_stateMachine) {
-                            if (m_pending == promise) {
-                                Move(Commands.Fail);
-                                m_pending = null;
-                                m_lastError = new OperationCanceledException("The operation has been cancelled", r);
-                            }
-
-                        }
+                        // handle cancellation as exception
                         throw new OperationCanceledException("The operation has been cancelled", r);
                     }
                 );
@@ -201,7 +194,7 @@
             if (current == null) {
                 stop.Resolve();
             } else {
-                current.On(stop.Resolve, stop.Reject, stop.CancelOperation);
+                current.On(stop.Resolve, stop.Reject, e => stop.Resolve());
                 current.Cancel();
             }
         }