private static async Task Async_Tick(object stateInfo) { _asyncNow = DateTime.Now; // _asyncToday = DateTime.Today; try { if ((_asyncNow - _lastOnlineCheck).TotalSeconds > 5) { _lastOnlineCheck = _asyncNow; if (!await APIHelper.ESIAPI.IsServerOnline("General")) { if (IsConnected) { await LogHelper.LogWarning("EVE server is offline or there is a connection problem!", LogCat.ESI); await LogHelper.LogWarning("Waiting for connection....", LogCat.ESI); } IsNoConnection = true; } else { if (IsNoConnection) { IsNoConnection = false; await LogHelper.LogWarning("EVE server is ONLINE or connection has been restored!", LogCat.ESI, true, false); } } } await ContinuousCheckModule.OneSec_TQStatusPost(_asyncNow); if (IsNoConnection) { return; } Parallel.ForEach(Modules, module => module.Run(null)); } catch (Exception ex) { await LogHelper.LogEx(ex.Message, ex, LogCat.Tick); } finally { _running = false; } }
public static async void Tick(object stateInfo) { if (_running || !APIHelper.DiscordAPI.IsAvailable) { return; } _running = true; _asyncNow = DateTime.Now; try { if (!_isModulesLoaded) { await LoadModules(); _isModulesLoaded = true; } #region ONLINE CHECK if ((_asyncNow - _lastOnlineCheck).TotalSeconds > 5) { _lastOnlineCheck = _asyncNow; var onlineType = await APIHelper.ESIAPI.IsServerOnlineEx("General"); IsESIUnreachable = onlineType == -1; if (onlineType != 1) { if (IsConnected) { if (onlineType == 0) { await LogHelper.LogWarning("EVE server is offline!", LogCat.ESI); } if (onlineType == -1) { await LogHelper.LogWarning("EVE ESI API is unreachable!", LogCat.ESI); } await LogHelper.LogWarning("Waiting for connection....", LogCat.ESI); } IsNoConnection = true; } else { if (IsNoConnection) { IsNoConnection = false; await LogHelper.LogWarning("EVE server is ONLINE or connection has been restored!", LogCat.ESI, true, false); } } } #endregion await ContinuousCheckModule.OneSec_TQStatusPost(_asyncNow); if (IsNoConnection || IsESIUnreachable) { return; } await Modules.ParallelForEachAsync(async module => { await module.Run(null); }, SettingsManager.MaxConcurrentThreads); } catch (Exception ex) { await LogHelper.LogEx(ex.Message, ex, LogCat.Tick); } finally { _running = false; } }