示例#1
0
 public void SessionEndingEvent(object sender, EventArgs ev)
 {
     // queue exit
     Log.Information("<Session:Ending> Exiting...");
     BeginInvoke(new Action(() => {
         Microsoft.Win32.SystemEvents.SessionEnding -= SessionEndingEvent;
         Taskmaster.UnifiedExit();
     }));
 }
示例#2
0
        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();
            }
        }
示例#3
0
        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();
            }
        }
示例#4
0
        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);
            }
        }