예제 #1
0
        public async Task StartJob()
        {
            Job currentJob;

            if (PendingJobs.NotEmpty() && !Cancelled)
            {
                lock (PendingJobs)
                    currentJob = PendingJobs.Dequeue();
                lock (ScheduledJobs)
                    ScheduledJobs.Add(currentJob);
                await jobSemaphore.WaitAsync();

                if (ScheduledJobs.NotEmpty() && !Cancelled)
                {
                    lock (ScheduledJobs)
                        ScheduledJobs.Remove(currentJob);
                    lock (ExecutingJobs)
                        ExecutingJobs.Add(currentJob);
                    await currentJob.Execute(ImageMaker);

                    if (!Cancelled)
                    {
                        lock (ExecutingJobs)
                            ExecutingJobs.Remove(currentJob);
                    }
                    jobSemaphore.Release();
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Moves the provided <see cref="GeolocationBatchUpdateJob"/> from pending to executing
 /// </summary>
 /// <param name="job">The <see cref="GeolocationBatchUpdateJob"/> to move</param>
 private void MovePendingToExecuting(GeolocationBatchUpdateJob job)
 {
     PendingJobs.Remove(job);
     ExecutingJobs.Add(job);
     Buffer.Add(job.Id, job.Request as List <IPGeolocationUpdateRequest>);
 }