public override Task StopAsync(CancellationToken cancellationToken) { _logger.LogInformation($"Worker stopped at: {DateTime.Now}"); if (_exchangePluginService.PluginExchanges == null || !_exchangePluginService.PluginExchanges.Any()) { return(base.StopAsync(cancellationToken)); } for (int i = _exchangePluginService.PluginExchanges.Count - 1; i >= 0; i--) { AbstractExchangePlugin abstractExchangePlugin = _exchangePluginService.PluginExchanges[i]; abstractExchangePlugin.CloseFeed().GetAwaiter(); } return(base.StopAsync(cancellationToken)); }
public override async void Dispose() { _logger.LogInformation($"Worker disposed at: {DateTime.Now}"); if (_exchangePluginService.PluginExchanges != null && _exchangePluginService.PluginExchanges.Any()) { for (int i = _exchangePluginService.PluginExchanges.Count - 1; i >= 0; i--) { AbstractExchangePlugin abstractExchangePlugin = _exchangePluginService.PluginExchanges[i]; await abstractExchangePlugin.CloseFeed(); abstractExchangePlugin.Dispose(); } } base.Dispose(); }