예제 #1
0
 public void Working(IJob job)
 {
     if (job != null)
     {
         job.DoJob();
     }
 }
예제 #2
0
 public void DoWork(IJob job)
 {
     if (job != null)
     {
         job.DoJob();
     }
 }
예제 #3
0
 private Task CreateTask()
 {
     return(new Task(() =>
     {
         while (!_isCanceled)
         {
             try
             {
                 token.ThrowIfCancellationRequested();
                 StartProcess();
                 JobResult(_job.DoJob());
                 SpinWait.SpinUntil(() => false, NextInterval());
             }
             catch (OperationCanceledException)
             {
                 break;
             }
             catch (System.Exception ex)
             {
                 var isRetry = CheckRetry();
                 if (!isRetry.Item1)
                 {
                     AfterExceptionCanceled(ex);
                     throw;
                 }
                 OnRetry(isRetry.Item2);
                 SpinWait.SpinUntil(() => false, RetryInterval());
             }
         }
         AfterCanceled();
     }, token));
 }
예제 #4
0
 public void DoJob()
 {
     if (_job != null)
     {
         _job.DoJob();
     }
 }
예제 #5
0
        static void Main(string[] args)
        {
            IEmployee myEmployee = Factory.CreateIEmployee();

            myEmployee.Name    = "Mert";
            myEmployee.Surname = "Yavuz";
            myEmployee.Age     = 25;


            IJob job = Factory.CreateIJob();

            job.Employee = myEmployee;
            job.JobName  = "Doing an IoC presentation";


            job.DoJob(2);
            job.DoJob(1);
            job.FinishJob();
        }
예제 #6
0
        public void ConsumeJobs()
        {
            while (true)
            {
                if (_cancellationToken.IsCancellationRequested)
                {
                    return;
                }

                if (!this._jobQueue.Empty())
                {
                    Task.Run(() =>
                    {
                        IJob job = null;
                        if (this._jobQueue.TryDequeue(out job))
                        {
                            try
                            {
                                _jobManager.JobStarted(job.JobId);
                                job.DoJob(_cancellationToken);
                                _jobManager.JobCompleted(job.JobId);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.Message);
                                _jobManager.JobFailed(job.JobId);
                            }
                        }
                    });
                }
                else
                {
                    Thread.Sleep(500);
                }
            }
        }
예제 #7
0
        private void doJob(JobItem item, bool nextSchedule = true)
        {
            if (item.Pending == true)
            {
                return;
            }

            var type = Type.GetType(item.AssemblyQualifiedName);

            if (type == null)
            {
                _jobItems.Remove(item);
            }
            else
            {
                IJob job = (IJob)type.Assembly.CreateInstance(type.FullName);
                job.DoJob();
                if (nextSchedule)
                {
                    item.Schedule = job.GetScheduleToNextTurn(item.Schedule);
                }
                job.Dispose();
            }
        }
예제 #8
0
 public void DoWork(IJob job)
 {
     job?.DoJob();
 }
 public void PlusName(int i)
 {
     job.DoJob(i);
 }
 public void ReName(int i)
 {
     job.DoJob(i);
 }