public void CancelCurrentOrder() { if (_isOrderCanceling || !_isAnyOrdersInWork) // TODO добавил. проверить, не проебать { return; } _isOrderCanceling = true; _strategy.AddWarningLog($"TRY TO CANCEL ORDER {_currentOrder}, {_strategy.Name}: {_strategy.ProcessState}"); if (_currentOrder == null) { _isOrderCanceling = false; _strategy.AddErrorLog("have no order to cancel: " + _currentOrder); return; } _currentOrder.WhenChanged(_strategy.Connector) .Do(o => { if (o.State == OrderStates.Done || o.State == OrderStates.Failed) { _strategy.AddWarningLog($"NOTE THAT ORDER CANCELED {_currentOrder}, {_strategy.Name}: {_strategy.ProcessState}"); _eventWaiter.Set(); } }) .Until(() => _currentOrder.State == OrderStates.Done || _currentOrder.State == OrderStates.Failed) .Apply(_strategy); _strategy.CancelOrder(_currentOrder); ContinueOrTimeout(() => { IsAnyOrdersInWork = false; _isOrderCanceling = false; }); }