예제 #1
0
        private void ExecuteTasks()
        {
            int errorTasks = 0;

            Parallel.ForEach(_ParallelTasks, PumpConfig.ParallelOption, task =>
            {
                if (task.Execute() == false)
                {
                    Interlocked.Increment(ref errorTasks);
                }
            });

            using (DbAccess dbAccess = DbPackage.CreateConnection())
            {
                ParallelTask callbackTask = (errorTasks > 0) ? _FailCallbackTask : _SuccessCallbackTask;

                if (callbackTask != null)
                {
                    callbackTask.Execute(dbAccess);
                }

                dbAccess.CompleteParallelJob(_PJobID);
            }

            Dispose();
        }
예제 #2
0
        public void Run(DbAccess dbAccess, PumpSynchronizer synchronizer)
        {
            dbAccess.RunParallelJob(_PJobID, task =>
            {
                ParallelTask parallelTask = new ParallelTask(
                    task.Field <int>("PJOB_ID"),
                    task.Field <short>("TASK_ID"),
                    task.Field <short>("COMMAND_TIMEOUT")
                    );

                switch (parallelTask.TaskID)
                {
                case 0:
                    _SuccessCallbackTask = parallelTask;
                    break;

                case -1:
                    _FailCallbackTask = parallelTask;
                    break;

                default:
                    _ParallelTasks.Add(parallelTask);
                    break;
                }
            });

            if (_ParallelTasks.Count > 0)
            {
                synchronizer.StartNewTask(() => { ExecuteTasks(); });
            }
        }
예제 #3
0
 public void Dispose()
 {
     _ParallelTasks.Clear();
     _SuccessCallbackTask = null;
     _FailCallbackTask    = null;
 }