private ThreadStart AllJobs()
 {
     return(() => executeWithExecutor(executor =>
     {
         CleanupJob job = null;
         do
         {
             try
             {
                 job = _jobs.poll(100, TimeUnit.MILLISECONDS);
                 if (job != null)
                 {
                     job.Run(executor);
                 }
             }
             catch (Exception)
             {
                 // There's no audience for these exceptions. The jobs themselves know if they've failed and communicates
                 // that to its tree. The scheduled job is just a vessel for running these cleanup jobs.
             }
             finally
             {
                 if (job != null)
                 {
                     job.Close();
                 }
             }
         } while (!_jobs.Empty || !_started);
         // Even if there are no jobs in the queue then continue looping until we go to started state
     }));
 }
Example #2
0
 public override void Add(CleanupJob job)
 {
     ExecuteWithExecutor(executor =>
     {
         try
         {
             job.Run(executor);
         }
         finally
         {
             job.Close();
         }
     });
 }
Example #3
0
        private async void btnProcess_Click(object sender, EventArgs e)
        {
            SetState(AppState.Processing);
            m_ProcessCancelSource = new CancellationTokenSource();

            var cleanupJob = new CleanupJob(m_LoadedRootFolder, m_CleanupJobSettings, m_ProcessCancelSource.Token);

            cleanupJob.ProgressUpdate += JobOnProgressUpdate;

            await cleanupJob.Run();

            cleanupJob.ProgressUpdate -= JobOnProgressUpdate;

            if (m_ProcessCancelSource.IsCancellationRequested)
            {
                lblFilesProcessed.Text += " (Cancelled)";
            }

            SetState(AppState.Loaded);
        }