//todo - make Exit wait until this returns private void LoadingThreadCommandLine() { Logging.RecordLogEvent("Initing/Loading Config", Logging.LogFilterType.Debug); System.Diagnostics.Stopwatch timer = new(); timer.Start(); GlobalConfig.LoadConfig(GUI: false); // 900ms~ depending on themes Logging.RecordLogEvent($"Startup: config loaded in {timer.ElapsedMilliseconds} ms", Logging.LogFilterType.Debug); timer.Restart(); rgatState.processCoordinatorThreadObj = new ProcessCoordinatorThread(); rgatState.processCoordinatorThreadObj.Begin(); // api data is the startup item that can be loaded latest as it's only needed when looking at traces // we could load it in parallel with the widgets/config but if it gets big then it will be the limiting factor in start up speed // doing it last means the user can do stuff while it loads Task?apiTask = null; if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) { string?datafile = APIDetailsWin.FindAPIDatafile(); if (datafile is not null) { apiTask = Task.Run(() => APIDetailsWin.Load(datafile)); } } else { apiTask = Task.Run(() => Logging.WriteConsole("TODO: linux API loading")); } /* * if (GlobalConfig.Settings.Updates.DoUpdateCheck) * { * _ = Task.Run(() => Updates.CheckForUpdates()); //functionality does not depend on this so we don't wait for it * } */ if (apiTask is not null) { Task.WhenAll(apiTask); } coordThread = new ProcessCoordinatorThread(); coordThread.Begin(); timer.Stop(); Logging.WriteConsole("Startup done"); }
//todo - make Exit wait until this returns private async void LoadingThread() { Logging.RecordLogEvent("Constructing rgatUI: Initing/Loading Config", Logging.LogFilterType.Debug); double currentUIProgress = rgatUI.StartupProgress; Stopwatch timer = new(), timerTotal = new(); timer.Start(); timerTotal.Start(); float configProgress = 0, widgetProgress = 0; void UpdateProgressConfWidgets() { rgatUI.StartupProgress = Math.Max(rgatUI.StartupProgress, currentUIProgress + 0.2 * configProgress + 0.5 * widgetProgress); }; Progress <float> IProgressConfig = new(progress => { configProgress = progress; UpdateProgressConfWidgets(); }); Progress <float> IProgressWidgets = new(progress => { widgetProgress = progress; UpdateProgressConfWidgets(); }); Task confloader = Task.Run(() => { GlobalConfig.LoadConfig(GUI: true, progress: IProgressConfig); }); // 900ms~ depending on themes Task widgetLoader = Task.Run(() => _rgatUI !.InitWidgets(IProgressWidgets)); //2000ms~ fairly flat await Task.WhenAll(widgetLoader, confloader); if (GlobalConfig.Settings.UI.EnabledLanguageCount > 0) { _controller !.RebuildFonts(); } InitEventHandlers(); Logging.RecordLogEvent($"Startup: Widgets+config loaded in {timer.ElapsedMilliseconds} ms", Logging.LogFilterType.Debug); timer.Restart(); rgatUI.StartupProgress = 0.85; currentUIProgress = rgatUI.StartupProgress; rgatState.VideoRecorder.Load(); //0 ms _rgatUI !.InitSettingsMenu(); //50ms ish Logging.RecordLogEvent($"Startup: Settings menu loaded in {timer.ElapsedMilliseconds} ms", Logging.LogFilterType.Debug); timer.Restart(); heatRankThreadObj = new HeatRankingThread(); heatRankThreadObj.Begin(); rgatState.processCoordinatorThreadObj = new ProcessCoordinatorThread(); rgatState.processCoordinatorThreadObj.Begin(); rgatUI.StartupProgress = 0.86; currentUIProgress = rgatUI.StartupProgress; float apiProgress = 0, sigProgress = 0; void UpdateProgressAPISig() { rgatUI.StartupProgress = Math.Max(rgatUI.StartupProgress, currentUIProgress + 0.07 * sigProgress + 0.07f * apiProgress); }; Progress <float> IProgressAPI = new(progress => { apiProgress = progress; UpdateProgressAPISig(); }); Progress <float> IProgressSigs = new(progress => { sigProgress = progress; UpdateProgressAPISig(); }); Task sigsTask = Task.Run(() => rgatState.LoadSignatures(IProgressSigs)); // api data is the startup item that can be loaded latest as it's only needed when looking at traces // we could load it in parallel with the widgets/config but if it gets big then it will be the limiting factor in start up speed // doing it last means the user can do stuff while it loads Task?apiTask = null; if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) { string?datafile = APIDetailsWin.FindAPIDatafile(); if (datafile is not null) { apiTask = Task.Run(() => APIDetailsWin.Load(datafile, IProgressAPI)); } else { apiTask = Task.Delay(0); Logging.RecordError("Failed to find API data file"); } } else { apiTask = Task.Run(() => Logging.WriteConsole("TODO: linux API loading")); } if (GlobalConfig.Settings.Updates.DoUpdateCheck) { _ = Task.Run(() => Updates.CheckForUpdates()); //functionality does not depend on this so we don't wait for it } await Task.WhenAll(sigsTask, apiTask); timer.Stop(); timerTotal.Stop(); Logging.RecordLogEvent($"Startup: Signatures + API info inited in {timer.ElapsedMilliseconds} ms", Logging.LogFilterType.Debug); Logging.RecordLogEvent($"Startup: Loading thread took {timerTotal.ElapsedMilliseconds} ms", Logging.LogFilterType.Debug); rgatUI.StartupProgress = 1; }