private void RunThreaded() { while (IsRunning) { bool updatedJobs = false; lock ( JobListLock ) { for (int i = Jobs.Count - 1; i >= 0; --i) { var job = Jobs[i]; if (ProcessJob(job)) { updatedJobs = true; Jobs.RemoveAt(i); UpdateJobList(); } } } if (updatedJobs) { lock ( JobListLock ) { JobListUpdated?.Invoke(this, EventArgs.Empty); } } Thread.Sleep(SleepTime); } }
public void DeleteJob(SchedulerJob job) { lock ( JobListLock ) { Jobs.Remove(job); UpdateJobList(); } lock ( JobListLock ) { JobListUpdated?.Invoke(this, EventArgs.Empty); } }
public void AddJob(SchedulerJob job) { Debug.Assert(job.AccountIds.Any()); Debug.Assert(!string.IsNullOrEmpty(job.Text)); lock ( JobListLock ) { job.JobId = JobIdCounter++; Jobs.Add(job); UpdateJobList(); } lock ( JobListLock ) { JobListUpdated?.Invoke(this, EventArgs.Empty); } }