private void MainProcess(bool restarting = false) { try { ThreadHelper.SafeSleep(4000); if (!restarting) { LoadDb().Wait(); } SetConnectToYouTubeButtonEnabled(true); CheckForLatestVersion(); Logger.LogInfo("MainProcess", "File scanner starting"); FileScanner.Process(); Logger.LogInfo("MainProcess", "File scan complete"); YTMAuthenticationCheckWait(); RepopulateAmountLables(); Logger.LogInfo("MainProcess", "Starting upload check and upload process"); FileUploader.Process().Wait(); Logger.LogInfo("MainProcess", "Upload check and process upload process complete"); YTMAuthenticationCheckWait(); RepopulateAmountLables(); if (Settings.UploadPlaylists) { if (!Settings.LastPlaylistUpload.HasValue) { Settings.LastPlaylistUpload = DateTime.Now.AddHours(Global.SessionRestartHours * -1).AddHours(-2); } if (DateTime.Now > ((DateTime)Settings.LastPlaylistUpload).AddHours(Global.SessionRestartHours)) { Logger.LogInfo("MainProcess", "Starting playlist processing"); PlaylistProcessor.Process(); Logger.LogInfo("MainProcess", "Playlist processing complete"); } } if (ManagingYTMusicStatus != ManagingYTMusicStatusEnum.Showing) { SetStatusMessage("Idle", "Idle"); SetUploadingMessage("Idle", null, "Idle", null, true); } if (WatchFolders.Count == 0) { SetAmountLabelsToZero(); } else { RepopulateAmountLables(true); } ThreadHelper.SafeSleep(10000); } catch (Exception e) { string _ = e.Message; #if DEBUG Console.Out.WriteLine("Main Process Thread Error: " + e.Message); #endif if (e.Message.ToLower().Contains("thread was being aborted") || (e.InnerException != null && e.InnerException.Message.ToLower().Contains("thread was being aborted"))) { // Non-detrimental - Ignore to not clog up the application log // Logger.Log(e, "Main Process thread error", Log.LogTypeEnum.Warning); } else { Logger.Log(e, "Main Process thread error", Log.LogTypeEnum.Critical); } } IdleProcessor.Paused = false; GCCollect(); }
private void MainProcess(bool restarting = false) { try { ThreadHelper.SafeSleep(4000); if (!restarting) { LoadDb().Wait(); } while (InstallingEdge) { ThreadHelper.SafeSleep(200); } CheckForLatestVersion(); Logger.LogInfo("MainProcess", "File scanner starting"); FileScanner.Process(); Logger.LogInfo("MainProcess", "File scan complete"); YTMAuthenticationCheckWait(); RepopulateAmountLables(); Logger.LogInfo("MainProcess", "Starting upload check and upload process"); FileUploader.Process().Wait(); Logger.LogInfo("MainProcess", "Upload check and process upload process complete"); YTMAuthenticationCheckWait(); RepopulateAmountLables(); Logger.LogInfo("MainProcess", "Starting playlist processing"); PlaylistProcessor.Process(); Logger.LogInfo("MainProcess", "Playlist processing complete"); if (ManagingYTMusicStatus != ManagingYTMusicStatusEnum.Showing) { SetStatusMessage("Idle", "Idle"); SetUploadingMessage("Idle", "Idle", null, true); } if (WatchFolders.Count == 0) { SetAmountLabelsToZero(); } else { RepopulateAmountLables(true); } ThreadHelper.SafeSleep(10000); } catch (Exception e) { string _ = e.Message; #if DEBUG Console.Out.WriteLine("Main Process Thread Error: " + e.Message); #endif if (e.Message.ToLower().Contains("thread was being aborted") || (e.InnerException != null && e.InnerException.Message.ToLower().Contains("thread was being aborted"))) { // Non-detrimental - Ignore to not clog up the application log // Logger.Log(e, "Main Process thread error", Log.LogTypeEnum.Warning); } else { Logger.Log(e, "Main Process thread error", Log.LogTypeEnum.Critical); } } IdleProcessor.Paused = false; }