Пример #1
0
        private ReturnT PushJobQueue(TriggerParam triggerParam, ITaskExecutor executor)
        {
            if (RUNNING_QUEUE.TryGetValue(triggerParam.JobId, out var jobQueue))
            {
                return(jobQueue.Push(triggerParam));
            }

            //NewJobId
            jobQueue           = new JobTaskQueue(executor, this._jobLogger, this._jobQueueLogger);
            jobQueue.CallBack += TriggerCallback;
            if (RUNNING_QUEUE.TryAdd(triggerParam.JobId, jobQueue))
            {
                return(jobQueue.Push(triggerParam));
            }
            return(ReturnT.Failed("add running queue executor error"));
        }
Пример #2
0
        private ReturnT ChangeJobQueue(TriggerParam triggerParam, ITaskExecutor executor)
        {
            if (RUNNING_QUEUE.TryRemove(triggerParam.JobId, out var oldJobTask))
            {
                oldJobTask.CallBack -= TriggerCallback;
                oldJobTask.Dispose(); //释放原来的资源
            }

            JobTaskQueue jobQueue = new JobTaskQueue(executor, this._jobLogger, this._jobQueueLogger);

            jobQueue.CallBack += TriggerCallback;
            if (RUNNING_QUEUE.TryAdd(triggerParam.JobId, jobQueue))
            {
                return(jobQueue.Push(triggerParam));
            }
            return(ReturnT.Failed(" replace running queue executor error"));
        }