private void ProcessJobsQueue()
{
for (int jobIndex = 0; jobIndex < this.activeJobsQueue.Count; jobIndex++)
{
Job job = this.activeJobsQueue[jobIndex];
if (job.CanStart())
{
job.Start();
}
if (job.IsRunning)
{
job.UpdateState();
}
if (job.IsFinished)
{
// Terminate any job actions, which still run on the background
job.Cancel();
// Move the current job to the "completed jobs" list
this.activeJobsQueue.RemoveAt(jobIndex);
this.completedJobs.Add(job);
// Continue correctly to the next job (after the current job, which is deleted)
jobIndex--;
}
this.RefreshActiveJobsUI();
}
}