Ejemplo n.º 1
0
 public void Remove(StandaloneJob job)
 {
     foreach (var queueJob in _readyToStart.Where(qj => qj.Job == job))
     {
         queueJob.IsCancelled = true;
     }
 }
Ejemplo n.º 2
0
 public bool TryDequeue(out StandaloneJob job)
 {
     QueueJob queueJob;
     if (_readyToStart.TryDequeue(out queueJob))
     {
         if (queueJob.IsCancelled)
         {
             return TryDequeue(out job);
         }
         job = queueJob.Job;
         return true;
     }
     job = null;
     return false;
 }
        private void ProcessCommand(CreateCommand command)
        {
            var jobToCreate = new StandaloneJob
            {
                Id = Interlocked.Increment(ref _lastTaskId),
                Iterations = command.Iterations,
                DelayInSeconds = command.DelayInSeconds
            };
            jobToCreate.RequiredJobs.AddRange(command.DependentTaskIds.Select(id => _allJobs.Single(t => t.Id == id)));

            _allJobs.Add(jobToCreate);

            if (command.StartUponCreation)
            {
                StartJob(jobToCreate);
            }
        }
 private void CancelJob(StandaloneJob job)
 {
     _jobQueue.Remove(job);
     job.Cancel();
 }
 private void StopJob(StandaloneJob job)
 {
     _jobQueue.Remove(job);
     _queueProcessor.Stop(job);
     job.Stop();
 }
 private void StartJob(StandaloneJob job)
 {
     if (job.HasRequirements)
     {
         _scheduler.Schedule(job);
     }
     else
     {
         _jobQueue.Enqueue(job);
     }
 }
Ejemplo n.º 7
0
 public void Schedule(StandaloneJob task)
 {
     task.Schedule().ContinueWith(t => _jobQueue.Enqueue(task), TaskContinuationOptions.NotOnCanceled);
 }
Ejemplo n.º 8
0
 public void Enqueue(StandaloneJob job)
 {
     job.Queue();
     _readyToStart.Enqueue(new QueueJob {Job = job});
     JobAdded?.Invoke(this, EventArgs.Empty);
 }