コード例 #1
0
        /// <summary>
        /// Try execute task.
        /// </summary>
        internal void TryStartTask()
        {
            var isCan = IsCanExecuteTask( );

            if (!isCan)
            {
                SetStatusFree();
            }
            else
            {
                this.SetStatusBusy();
                UpExecutionAttempt(currentTask);
                WorkerTaskStore.SetProccesStatus(currentTask);
                var executeThTask = new TaskFactory().StartNew(() =>
                {
                    try
                    {
                        _execution.Execute(currentTask);
                        WorkerTaskStore.SetSuccessStatus(currentTask);
                    }
                    catch
                    {
                        WorkerTaskStore.SetFailedStatus(currentTask);
                    }
                });
                executeThTask.Wait();
            }
        }
コード例 #2
0
 /// <summary>
 /// Try execute task.
 /// </summary>
 private void TryStartNextTask()
 {
     if (!IsCanExecuteTask())
     {
         SetStatusFree();
     }
     else
     {
         SetStatusBusy();
         UpExecutionAttempt(currentTask);
         WorkerTaskStore.SetProccesStatus(currentTask);
         try
         {
             _execution.Execute(currentTask);
             WorkerTaskStore.SetSuccessStatus(currentTask);
         }
         catch
         {
             WorkerTaskStore.SetFailedStatus(currentTask);
         }
     }
 }