void StartNextBackupTask(BackupProfileData profile) { BackupProcessWorkerTask task = null; lock (this) { int iBusyTasks = m_BackupWorkerTaskQueue.Where(t => (t.IsBusy == true)).Count(); if (iBusyTasks < MaxConcurrentTasks) { if (IsBackupWorkerBusy(profile) == true) { //Allow only one task to run for each profile at the same time task = m_BackupWorkerTaskQueue.Where(t => (t.IsBusy == false) && t.GetProfile() != profile).FirstOrDefault(); } else { task = m_BackupWorkerTaskQueue.Where(t => t.IsBusy == false).FirstOrDefault(); } } task?.RunWorkerAsync(); profile.IsBackupWorkerPending = true; //just sent onproperty change } if (task != null) { BackupProjectRepository.Instance.SelectedBackupProject.Logger.Writeln($"--> Starting new backup {task.GetProfile().Name}"); } }
BackupProcessWorkerTask GetPausedBackupWorkerTask(BackupProfileData profile) { BackupProcessWorkerTask task = null; // lock (this) { task = m_BackupWorkerTaskQueue.FirstOrDefault(w => (w.GetProfile() == profile) && w.IsBusy && (w.IsPaused == true)); } return(task); }
BackupProcessWorkerTask GetPendingBackupWorkerTask(BackupProfileData profile) { BackupProcessWorkerTask task = null; // lock (this) { task = m_BackupWorkerTaskQueue.FirstOrDefault(w => (w.GetProfile() == profile) && !w.IsBusy); } return(task); }
public void CompleteAndStartNextBackup(BackupProcessWorkerTask completedTask) { BackupProjectRepository.Instance.SelectedBackupProject.Logger.Writeln($"<-- Backup completed {completedTask.GetProfile().Name}"); completedTask.GetProfile().IsBackupWorkerBusy = false; //trigger onproperty change lock (this) { m_BackupWorkerTaskQueue.Remove(completedTask); } StartNextBackupTask(completedTask.GetProfile()); }