Follow these steps
- Add a first reference of Quartz.dll in your web application.
- Create a function which you want to execute repeatedly on a scheduled time.
Call the created function in same class
example- public void Execute(IJobExecutionContext context) {
- this.ScheduledTask();
- }
- Create a job (ex:name JobScheduler)(Function).
example- public static void Start() {
- // define the job and tie it to our HelloJob class
- IJobDetail job = JobBuilder.Create < EmailJob > ()
- .WithIdentity("myJob", "group1") // name "myJob", group "group1"
- .Build();
- // Trigger the job to run now, and then every 40 seconds
- ITrigger trigger = TriggerBuilder.Create()
- .WithIdentity("myTrigger", "group1")
- .StartNow()
- .WithSimpleSchedule(x => x
- //.WithIntervalInSeconds(300)
- .WithIntervalInMinutes(20)
- .RepeatForever())
- .Build();
- // Tell quartz to schedule the job using our trigger
- ISchedulerFactory sf = new StdSchedulerFactory();
- IScheduler sc = sf.GetScheduler();
- sc.ScheduleJob(job, trigger);
- sc.Start();
- }
- Add Global.asax.
- protected void Application_Start(object sender, EventArgs e) {
- JobScheduler.Start();
- }

Join the conversation! Your thoughts help the community grow.