/// <summary> /// For the given service, checks for new jobs that might be /// processed, and adds any that are found into the queue. /// </summary> /// <param name="source"></param> /// <param name="maxCount"></param> /// <returns></returns> private bool PopulateJobsForService(IProcessJobFactory source, int maxCount) { bool newJobs = false; Stopwatch watch = new Stopwatch("PopulateJobsForService"); if (maxCount > 0) { try { var jobs = source.GetPendingJobs(maxCount).Result; foreach (var job in jobs) { if (_jobQueue.TryAdd(job)) { newJobs = true; } } } catch (Exception ex) { Logging.LogError($"Exception getting jobs: {ex.Message}"); } } watch.Stop(); return(newJobs); }
/// <summary> /// Callback to notify the work service to look for new jobs. /// Will be called async, from another thread, and should /// process the PopulateJobs method on another thread and /// return immediately. /// </summary> /// <param name="source"></param> /// <param name="waitSeconds"></param> public void FlagNewJobs(IProcessJobFactory source) { Logging.Log($"Flagging new jobs state for {source.GetType().Name}"); Stopwatch watch = new Stopwatch("FlagNewJobs"); _newJobsFlag = true; watch.Stop(); }
public void AddJobSource(IProcessJobFactory source) { Logging.Log($"Registered job processing source: {source.GetType().Name}"); _jobSources.Add(source); }