private void check() { try { if (disposed) { return; } List <TJob> jobs = null; lock (list) { if (list.Count > 0) { jobs = list.ToList(); list.Clear(); } } if (jobs != null) { NewJobs?.Invoke(jobs); } } finally { if (!disposed) { timer.Start(); } } }
public void Start() { IsRunning = true; task.Start(); }
public JobDequeuer(int sleepMilliseconds) { list = new List <TJob>(); timer = new DelayedTask(check, sleepMilliseconds); timer.Start(); }