Exemple #1
0
        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);
            }
        }
Exemple #2
0
        public void DeleteJob(SchedulerJob job)
        {
            lock ( JobListLock )
            {
                Jobs.Remove(job);
                UpdateJobList();
            }

            lock ( JobListLock )
            {
                JobListUpdated?.Invoke(this, EventArgs.Empty);
            }
        }
Exemple #3
0
        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);
            }
        }