public void SessionEndingEvent(object sender, EventArgs ev) { // queue exit Log.Information("<Session:Ending> Exiting..."); BeginInvoke(new Action(() => { Microsoft.Win32.SystemEvents.SessionEnding -= SessionEndingEvent; Taskmaster.UnifiedExit(); })); }
async Task CheckErrors() { await Task.Delay(0).ConfigureAwait(false); // TODO: Maybe make this errors within timeframe instead of total...? if (Statistics.FatalErrors >= Settings.FatalErrorThreshold) { Log.Fatal("<Auto-Doc> Fatal error count too high, exiting."); Taskmaster.UnifiedExit(); } }
async Task CheckLogs() { await Task.Delay(0).ConfigureAwait(false); long size = 0; var files = System.IO.Directory.GetFiles(logpath, "*", System.IO.SearchOption.AllDirectories); foreach (var filename in files) { var fi = new System.IO.FileInfo(System.IO.Path.Combine(logpath, filename)); size += fi.Length; } if (size >= Settings.FatalLogSizeThreshold * 1_000_000) { Log.Fatal("<Auto-Doc> Log files exceeding allowed size, exiting."); Taskmaster.UnifiedExit(); } }
public async void EnsureVisible() { if (!Atomic.Lock(ref ensuringvisibility)) { return; } try { Enable(); int attempts = 0; while (!Tray.Visible) { Log.Debug("<Tray> Not visible, fixing..."); RefreshVisibility(); await Task.Delay(15 * 1000).ConfigureAwait(true); if (++attempts >= 5) { Log.Fatal("<Tray> Failure to become visible after 5 attempts. Exiting to avoid ghost status."); Taskmaster.UnifiedExit(); } } } catch (Exception ex) { Logging.Stacktrace(ex); } finally { Atomic.Unlock(ref ensuringvisibility); } }