示例#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);
 }