Example #1
0
        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}");
            }
        }
Example #2
0
        BackupProcessWorkerTask GetPausedBackupWorkerTask(BackupProfileData profile)
        {
            BackupProcessWorkerTask task = null;

            // lock (this)
            {
                task = m_BackupWorkerTaskQueue.FirstOrDefault(w => (w.GetProfile() == profile) && w.IsBusy && (w.IsPaused == true));
            }

            return(task);
        }
Example #3
0
        BackupProcessWorkerTask GetPendingBackupWorkerTask(BackupProfileData profile)
        {
            BackupProcessWorkerTask task = null;

            // lock (this)
            {
                task = m_BackupWorkerTaskQueue.FirstOrDefault(w => (w.GetProfile() == profile) && !w.IsBusy);
            }

            return(task);
        }
Example #4
0
        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());
        }