// подписка на данные /// <summary> /// переподключить скачивание свечек /// </summary> private void Reconnect() { try { if (_mySeries != null) { _mySeries.СandleUpdeteEvent -= MySeries_СandleUpdeteEvent; _mySeries.СandleFinishedEvent -= MySeries_СandleFinishedEvent; _mySeries.Stop(); _mySeries = null; } Save(); if (_subscrabler == null) { _subscrabler = new Thread(Subscrable); _subscrabler.CurrentCulture = new CultureInfo("ru-RU"); _subscrabler.IsBackground = true; _subscrabler.Name = "ConnectorSubscrableThread_" + UniqName; _subscrabler.Start(); if (NewCandlesChangeEvent != null) { NewCandlesChangeEvent(null); } } } catch (Exception error) { SendNewLogMessage(error.ToString(), LogMessageType.Error); } }
/// <summary> /// reconnect candle downloading /// переподключить скачивание свечек /// </summary> private void Reconnect() { try { lock (_reconnectLocker) { if (_lastReconnectTime.AddSeconds(1) > DateTime.Now) { if (ConnectorStartedReconnectEvent != null) { ConnectorStartedReconnectEvent(NamePaper, TimeFrame, TimeFrameTimeSpan, PortfolioName, ServerType); } return; } _lastReconnectTime = DateTime.Now; } if (_mySeries != null) { _mySeries.СandleUpdeteEvent -= MySeries_СandleUpdeteEvent; _mySeries.СandleFinishedEvent -= MySeries_СandleFinishedEvent; _mySeries.Stop(); _mySeries = null; } Save(); if (ConnectorStartedReconnectEvent != null) { ConnectorStartedReconnectEvent(NamePaper, TimeFrame, TimeFrameTimeSpan, PortfolioName, ServerType); } if (_subscrabler == null) { try { _subscrabler = new Thread(Subscrable); _subscrabler.CurrentCulture = new CultureInfo("ru-RU"); _subscrabler.IsBackground = true; _subscrabler.Name = "ConnectorSubscrableThread_" + UniqName; _subscrabler.Start(); } catch { } if (NewCandlesChangeEvent != null) { NewCandlesChangeEvent(null); } } } catch (Exception error) { SendNewLogMessage(error.ToString(), LogMessageType.Error); } }
/// <summary> /// reconnect candle downloading /// переподключить скачивание свечек /// </summary> private void Reconnect() { try { lock (_reconnectLocker) { if (_lastReconnectTime.AddSeconds(1) > DateTime.Now) { if (ConnectorStartedReconnectEvent != null) { ConnectorStartedReconnectEvent(SecurityName, TimeFrame, TimeFrameTimeSpan, PortfolioName, ServerType); } return; } _lastReconnectTime = DateTime.Now; } if (_mySeries != null) { _mySeries.СandleUpdeteEvent -= MySeries_СandleUpdeteEvent; _mySeries.СandleFinishedEvent -= MySeries_СandleFinishedEvent; _mySeries.Stop(); _mySeries = null; } Save(); if (ConnectorStartedReconnectEvent != null) { ConnectorStartedReconnectEvent(SecurityName, TimeFrame, TimeFrameTimeSpan, PortfolioName, ServerType); } if (_taskIsDead == true) { _taskIsDead = false; Task.Run(Subscrable); if (NewCandlesChangeEvent != null) { NewCandlesChangeEvent(null); } } } catch (Exception error) { SendNewLogMessage(error.ToString(), LogMessageType.Error); } }