private void Dispose() { try { if (AstsServer != null && AstsServer.IsConnected) { AstsServer.Disconnect(); } } catch (Exception error) { SendLogMessage(error.ToString(), LogMessageType.Error); } if (AstsServer != null) { AstsServer.ConnectedEvent -= Connected; AstsServer.DisconnectedEvent -= Disconnected; AstsServer.NewSecurityEvent -= NewSecurityEvent; AstsServer.PortfolioUpdateEvent -= AddPortfolio; AstsServer.NewTradesEvent -= NewTradesEvent; AstsServer.NewMyTradeEvent -= AddMyTrade; AstsServer.MarketDepthUpdateEvent -= UpdateBidAsk; AstsServer.OrderUpdateEvent -= UpdateOrder; AstsServer.OrderFailedEvent -= OrderFailedEvent; AstsServer.SecurityMoexUpdateEvent -= LevelOneUpdateEvent; } AstsServer = null; _getPortfoliosAndSecurities = false; }
/// <summary> /// приостановить подключение /// </summary> private void Disconnect() { AstsServer.Disconnect(); Thread.Sleep(5000); }