Home > Net >  Quartz.net dynamically modify the task execution cycles
Quartz.net dynamically modify the task execution cycles

Time:11-23

Demand is based on dynamic modifying Quartz configuration task, find a lot of information is a Java (for example, https://blog.csdn.net/u010377605/article/details/77801896), and.net method different fields
Now my code looks something like this (see https://blog.csdn.net/qq_18145031/article/details/81382280)
CronTriggerImpl trigger=new CronTriggerImpl (triggerName, triggerGroupName);
JobDetailImpl jobDetail=new JobDetailImpl (jobDetailName jobDetailGroupName, type);

//ITrigger trigger=(ITrigger) sched. GetTrigger (new TriggerKey (triggerName, triggerGroupName));
//IJobDetail jobDetail=(IJobDetail) sched. GetJobDetail (new JobKey (jobDetailName jobDetailGroupName));
If (the trigger!=null)
{

CronTriggerImpl ct=(CronTriggerImpl) trigger;
//remove the current process of Job
Bool flag=sched. DeleteJob (jobDetail. Key);
//modify the Trigger
Ct. CronExpressionString=time;
Console. WriteLine (" CronTrigger getName "+ ct. JobName);
//rescheduling jobDetail
Sched. ScheduleJob (jobDetail, ct);
}
Operation result is launched a new task with the same name, and the cycle is not incoming Cron expression, breakpoint at removing task under the returned flag is false, should be constructed on the trigger and jobDetail no construction, and this is the new way, according to the demand should be access to existing, but looking for a long time also watched but didn't find the original, for help! (https://quartznet.sourceforge.io/apidoc/3.0/html/)

CodePudding user response:


First instance attributes main fields:
The properties [quartz. The scheduler. "instanceId"]="here can give MAC address to ensure only";
The properties [quartz. The scheduler. "instanceName"]="here can give MAC address to ensure only";


The general restructuring of method is:
1, IScheduler do shutDown processing
2, new corn
3. Then Start again ()

About the cron expressions:
Online generation address: http://www.bejson.com/othertools/cron/

See website for more details:
https://www.quartz-scheduler.net/documentation/index.html


CodePudding user response:

That, not heavy

CodePudding user response:

I didn't ask to solve to I delete ah, administrator what were you thinking?

Solve the building Lord, can you share, online for a long time yet to find a solution.
I use or dependency injection, less information
After going to modify the XML configuration rules should restart to take effect
  •  Tags:  
  • C#
  • Related