Schedule Configuring the number of threads
If there are many tasks in a schedule, then the default 10 threads are not enough.
There are many ways to configure the number of threads.
Factory constructors
Webfonfig
Quartzconfig
Environment variables
Recommended use of Webconfig
Quartz.scheduler.instanceName =ExampleDefaultQuartzSchedulerquartz.threadPool.threadCount= theQuartz.jobStore.misfireThreshold=60000# Sample configuration based DB Providerquartz.dbprovider.customProvider.productName= Microsoft SQL Server, provider V2.0.0.0 inchFramework. NET V2.0Quartz.dbprovider.customProvider.assemblyName= System.Data, version=2.0.0.0, Culture=neutral, publickeytoken=B77a5c561934e089quartz.dbprovider.customProvider.connectionType= System.Data.SqlClient.SqlConnection, System.Data, version=2.0.0.0, Culture=neutral, publickeytoken=B77a5c561934e089quartz.dbprovider.customProvider.commandType= System.Data.SqlClient.SqlCommand, System.Data, version=2.0.0.0, Culture=neutral, publickeytoken=B77a5c561934e089quartz.dbprovider.customProvider.parameterType= System.Data.SqlClient.SqlParameter, System.Data, version=2.0.0.0, Culture=neutral, publickeytoken=B77a5c561934e089quartz.dbprovider.customProvider.parameterDbType= System.Data.SqlDbType, System.Data, version=2.0.0.0, Culture=neutral, publickeytoken=B77a5c561934e089quartz.dbprovider.customProvider.parameterDbTypePropertyName=SqlDbTypequartz.dbprovider.customProvider.parameterNamePrefix=@quartz. Dbprovider.customProvider.exceptionType= System.Data.SqlClient.SqlException, System.Data, version=2.0.0.0, Culture=neutral, publickeytoken=b77a5c561934e089quartz.dbprovider.customProvider.useParameterNamePrefixInParameterCollection=trueQuartz.dbprovider.customProvider.bindByName=trueQuartz.dbprovider.customProvider.dbBinaryTypeName= Image
View Code
Priority level
NameValueCollection Constructors > Environment Variables >app.config>web.config
The above is to modify the number of threadcount. is done by reflection. Of course, you can modify other variables as well.
Job Trigger configuration file
The benefits of the profile, without modifying the code, only modify the configuration file, you can dynamically update the task.
The configuration of the job and trigger is implemented via plugins. The source code in the plug-in project and quartz project separate, you need to manually merge into a project, or you will add three DLLs.
There is an XSD file in the source code, which is the schema of the job trigger configuration file. Add him to vs inside the XML will prompt the job and trigger XML code.
Xmlschedulingdataprocessor is a class that specializes in parsing job trigger configuration files. The configuration file default name is
<?xml version="1.0"encoding="UTF-8"? ><job-scheduling-data xmlns="Http://quartznet.sourceforge.net/JobSchedulingData"Xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"version="2.0"> <!--program directives--<processing-directives> <!--If the program has defined trigger and the job will be installed in this configuration file---<overwrite- Existing-data>true</overwrite-existing-data> <!--no matter the repetition. If it is true, the configuration that appears in this file will be ignored in the program. -<!--<ignore-duplicates></ignore-duplicates>--> </processing-directives> < schedule> <job> <name>xmlJob</name> <group>xmlJobGroupName</group> < Description>xmljob</description> <!--job class full name, assembly name---<job-type>frmtimingqu Artz. MyJob7, frmtimingquartz</job-type> <!--durability--<durable>true</durable> <!--Recovery--<recover>true</recover> <job-data-map> <entry> <key>name1</key> <VALUE&G t;wyx</value> </entry> <entry> <key>key2</key> <value> wdq</value> </entry> </job-data-map> </job> <trigger> <!--four flip flops--& Gt <!--http://www.cnblogs.com/wudequn/p/8506938.html--><calendar-interval> </calendar-interval> <simple> <name>xmlTrigger</name> <description>xmlTrigger</description> <job-name>xmlJob</job-name> <job-grou P>xmljobgroupname</job-group> <priority></priority> <!---1 Infinity-and <repea t-count>-1</repeat-count> < How often!--poll--<repeat-interval> +</repeat-interval> </simple> </trigger> </schedule></job-scheduling-data>
configuration file
Private Async voidButton16_click (Objectsender, EventArgs e) { //Quartz.plugin.xml.type The first part is the full name of the class the second part is the assembly where the class residesNameValueCollection NVC =NewNameValueCollection () {["Quartz.plugin.xml.type"] ="Quartz.plugin.xml.xmlschedulingdataprocessorplugin,quartz.plugins, Quartz.plugins", ["Quartz.plugin.xml.fileNames"] ="~/quartz_jobs.xml", //Three seconds is a configuration file, this parameter allows you to modify the configuration file and do not have to restart the program. ["Quartz.plugin.xml.ScanInterval"] ="3" }; //initializes all of his properties through Namevalue. vartf =Newstdschedulerfactory (NVC); varSche =awaitTF. Getscheduler (); awaitSche. Start (); }
Calling code
quartz.net-Configuration