public void Restart() { Aborting = true; ThreadPool.QueueUserWorkItem(delegate { while ( !FileScanner.Stopped || !FileUploader.Stopped || !PlaylistProcessor.Stopped || !IdleProcessor.Stopped || !QueueChecker.Stopped) { ThreadHelper.SafeSleep(250); } FileScanner = new FileScanner(this); FileUploader = new FileUploader(this); IdleProcessor = new IdleProcessor(this); QueueChecker = new QueueChecker(this); PlaylistProcessor = new PlaylistProcessor(this); FileScanner.Reset(); Aborting = false; ManagingYTMusicStatus = ManagingYTMusicStatusEnum.CloseChangesComplete; StartMainProcess(true); }); }
private void OnAddTrack() { _playlistProcessor = new PlaylistProcessor(_tracksInPlaylist); _addTrackCommandCustom = new AddTrackCommandCustom(_playlistProcessor, _selectedTrack); _invoker.SetCommand(_addTrackCommandCustom); _invoker.Invoke(); }
private void OnRemoveTrack() { _playlistProcessor = new PlaylistProcessor(_tracksInPlaylist); _removeTrackCommandCustom = new RemoveTrackCommandCustom(_playlistProcessor, _selectedTrackInPlaylist); _invoker.SetCommand(_removeTrackCommandCustom); _invoker.Invoke(); }
public MainForm(bool hidden) : base(formResizable: false) { #if RELEASE CheckForIllegalCrossThreadCalls = false; #endif CultureHelper.GloballySetCultureToGB(); MainFormInstance = this; InitializeComponent(); if (hidden) { ShowInTaskbar = false; CenterForm(); WindowState = FormWindowState.Minimized; Opacity = 0; StartHidden = true; } MusicDataFetcher = new MusicDataFetcher(); SetVersion("v" + Global.ApplicationVersion); lblIssues.GotFocus += LinkLabel_GotFocus; lblDiscoveredFiles.GotFocus += LinkLabel_GotFocus; if (!EdgeDependencyChecker.CheckEdgeCoreFilesArePresentAndCorrect()) { btnConnectToYoutube.Enabled = false; InstallEdge(); } else { ConnectToYTMusicForm = new ConnectToYTMusic(this); } FileScanner = new FileScanner(this); FileUploader = new FileUploader(this); PlaylistProcessor = new PlaylistProcessor(this); IdleProcessor = new IdleProcessor(this); QueueChecker = new QueueChecker(this); InitialiseTimers(); InitialiseTooltips(); InitialiseSystemTrayIconMenuButtons(); ConnectToYouTubeMusic(); StartMainProcess(); }
public RemoveTrackCommandCustom(PlaylistProcessor playlistProcessor, Track track) { _playlistProcessor = playlistProcessor; _track = track; }
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(); }
public MainForm(bool hidden) : base(formResizable: false) { #if RELEASE CheckForIllegalCrossThreadCalls = false; #endif CultureHelper.GloballySetCultureToGB(); MainFormInstance = this; InitializeComponent(); btnConnectToYoutube.Enabled = false; if (hidden) { ShowInTaskbar = false; CenterForm(); WindowState = FormWindowState.Minimized; Opacity = 0; StartHidden = true; } MusicDataFetcher = new MusicDataFetcher(); SetVersion("v" + Global.ApplicationVersion); lblIssues.GotFocus += LinkLabel_GotFocus; lblDiscoveredFiles.GotFocus += LinkLabel_GotFocus; ConnectToYTMusicForm = new ConnectToYTMusic(this); FileScanner = new FileScanner(this); FileUploader = new FileUploader(this); PlaylistProcessor = new PlaylistProcessor(this); IdleProcessor = new IdleProcessor(this); QueueChecker = new QueueChecker(this); InitialiseTimers(); InitialiseTooltips(); InitialiseSystemTrayIconMenuButtons(); ConnectToYouTubeMusic(); StartMainProcess(); // Restart everything after 24 hours (is the application is continually run) _restartThread = new Thread((ThreadStart) delegate { while (Settings == null) { ThreadHelper.SafeSleep(500); } while (true) { if (Settings.UploadPlaylists) { if (!Settings.LastPlaylistUpload.HasValue) { Settings.LastPlaylistUpload = DateTime.Now.AddHours(Global.SessionRestartHours * -1).AddHours(-2); } if (!_scanAndUploadThread.IsAlive && DateTime.Now > ((DateTime)Settings.LastPlaylistUpload).AddHours(Global.SessionRestartHours) && !PlaylistProcessor.ProcessingPlaylistsFinished) { StartMainProcess(); } } if (DateTime.Now.AddHours(Global.SessionRestartHours * -1) > SessionStart) { SessionStart = DateTime.Now; PlaylistProcessor.ProcessingPlaylistsFinished = false; StartMainProcess(); } ThreadHelper.SafeSleep(15000); } }) { IsBackground = true }; _restartThread.Start(); }
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; }