Mercurial > pub > ImplabNet
comparison Implab/Components/RunnableComponent.cs @ 199:43b1017ce100 v2
Слияние с default
author | cin |
---|---|
date | Fri, 14 Oct 2016 03:33:17 +0300 |
parents | 40d7fed4a09e |
children | 2651cb9a4250 |
comparison
equal
deleted
inserted
replaced
195:ea485487a424 | 199:43b1017ce100 |
---|---|
118 lock (m_stateMachine) { | 118 lock (m_stateMachine) { |
119 Move(cmd); | 119 Move(cmd); |
120 | 120 |
121 prev = m_pending; | 121 prev = m_pending; |
122 | 122 |
123 Action<Exception> errorOrCancel = e => { | |
124 if (e == null) | |
125 e = new OperationCanceledException(); | |
126 | |
127 lock (m_stateMachine) { | |
128 if (m_pending == promise) { | |
129 Move(Commands.Fail); | |
130 m_pending = null; | |
131 m_lastError = e; | |
132 } | |
133 } | |
134 throw new PromiseTransientException(e); | |
135 }; | |
136 | |
123 promise = task.Then( | 137 promise = task.Then( |
124 () => { | 138 () => { |
125 lock(m_stateMachine) { | 139 lock(m_stateMachine) { |
126 if (m_pending == promise) { | 140 if (m_pending == promise) { |
127 Move(Commands.Ok); | 141 Move(Commands.Ok); |
128 m_pending = null; | 142 m_pending = null; |
129 } | 143 } |
130 } | 144 } |
131 }, e => { | 145 }, |
132 lock(m_stateMachine) { | 146 errorOrCancel, |
133 if (m_pending == promise) { | 147 errorOrCancel |
134 Move(Commands.Fail); | |
135 m_pending = null; | |
136 m_lastError = e; | |
137 } | |
138 } | |
139 throw new PromiseTransientException(e); | |
140 } | |
141 ); | 148 ); |
142 | 149 |
143 m_pending = promise; | 150 m_pending = promise; |
144 } | 151 } |
145 | 152 |