Quartz.net Working Example

I could not find a working example for Quarts.net. The examples at Quart.net site, does not compile. Found out they are build against Quartz.net version 1.0. The following is a working Quartz.net example that is built against Quartz.net 2.0 (Latest). What this job does is write a text message, “Hello Job is executed” in the console every 5 sec.


Start a Visual Studio 2012 project. Select Windows Console Application. Name it Quartz1 or what ever you like.


Download Quartz.NET assembly using NUGET. Right click on project, select “Manage Nuget Packages”. Then search for Quart.NET. Once found select and install. Note that you have to have online connection for this.

Copy and past the following Code

using System;
using System.Collections.Generic;
using Quartz;
using Quartz.Impl;

namespace Quartz1
    class Program
        static void Main(string[] args)
            // construct a scheduler factory
            ISchedulerFactory schedFact = new StdSchedulerFactory();

            // get a scheduler, start the schedular before triggers or anything else
            IScheduler sched = schedFact.GetScheduler();

            // create job
            IJobDetail job = JobBuilder.Create<SimpleJob>()
                        .WithIdentity("job1", "group1")

            // create trigger
            ITrigger trigger = TriggerBuilder.Create()
                .WithIdentity("trigger1", "group1")
                .WithSimpleSchedule(x => x.WithIntervalInSeconds(5).RepeatForever())

            // Schedule the job using the job and trigger 
            sched.ScheduleJob(job, trigger);


    /// <summary>
    /// SimpleJOb is just a class that implements IJOB interface. It implements just one method, Execute method
    /// </summary>
    public class SimpleJob : IJob
        void IJob.Execute(IJobExecutionContext context)
            //throw new NotImplementedException();
            Console.WriteLine("Hello, JOb executed");

How to delete Quartz.net job

This entry was posted in Software Development, Tutorials/Tips and tagged , , , , . Bookmark the permalink.

16 Responses to Quartz.net Working Example

  1. Ruan Fourie says:

    Thank you so much! The tutorials at the Quartz.net website isn’t working and there just isn’t any documentation out for it.

  2. Bjørn Otto Vasbotten says:

    Worked without a hitch, thank you. 🙂

  3. Bill Kindig says:

    Thanks! This is the only quartz “Hello World” I could find.

  4. reza says:

    thanks for your useful tutorial,
    I have a question about using quartz.net in website.
    i need to make a website that has a DB and i want to use quartz for search in website DB in any 12 hour.
    the user of website write his search key in a form and the website should search for this key any 12 hour and if that key will add to DB inform to the user by mail.
    any one here have solution ?
    thanks a lot my friends,

    • admin says:

      What I can think of, when the user enters a keyword, you store that keyword in the DB. When the Quartz.net job runs every 12 hours, it picks those keywords from DB and performs what every function you want to perform.

  5. Varaprasad says:

    I tried same in simple asp.net web application but it giving an below error

    Locating source for ‘c:\Work\OpenSource\quartznet\src\Quartz\Impl\StdSchedulerFactory.cs’. (No checksum.)
    The file ‘c:\Work\OpenSource\quartznet\src\Quartz\Impl\StdSchedulerFactory.cs’ does not exist.
    Looking in script documents for ‘c:\Work\OpenSource\quartznet\src\Quartz\Impl\StdSchedulerFactory.cs’…
    Looking in the projects for ‘c:\Work\OpenSource\quartznet\src\Quartz\Impl\StdSchedulerFactory.cs’.
    The file was not found in a project.
    Looking in directory ‘C:\Program Files\Microsoft Visual Studio 11.0\VC\crt\src\’…
    Looking in directory ‘C:\Program Files\Microsoft Visual Studio 11.0\VC\crt\src\vccorlib\’…
    Looking in directory ‘C:\Program Files\Microsoft Visual Studio 11.0\VC\atlmfc\src\mfc\’…
    Looking in directory ‘C:\Program Files\Microsoft Visual Studio 11.0\VC\atlmfc\src\atl\’…
    Looking in directory ‘C:\Program Files\Microsoft Visual Studio 11.0\VC\atlmfc\include’…
    The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: c:\Work\OpenSource\quartznet\src\Quartz\Impl\StdSchedulerFactory.cs.
    The debugger could not locate the source file ‘c:\Work\OpenSource\quartznet\src\Quartz\Impl\StdSchedulerFactory.cs’.

    • admin says:

      You have to download Quartz.net assembly. The following two reference requires that you have already downloaded it.

      using Quartz;
      using Quartz.Impl;

      In the tutorial, it says you can use NUGET to download the Quartz.net library. Or you can just download it independently and copy it to your project folder. Then add reference to this library before you can actually use it. Hope it helps.

  6. manoj says:


    i have query , how to get table from db and mail the table. Could you please help me.

  7. Haruni says:

    Thank you very much.
    At least i have something working.

  8. payam says:

    hi. it`s a great job, tnk u. but i want to d this some times and this come from my database jobs. what should i do for using this with certain date time??

  9. Omar says:

    Hello, your tutorial was very helpful thank you, can you add something related to adding job listeners? because nothing on the web I can find seems to work and most of the examples are in Java instead of C#

  10. Weeraa says:

    This code works fine. But when I publish as a web site in IIS, the scheduler run in every minutes even the schedule time set to every 5minutes, 6minutes, etc….. What ever time time change, it’s triggered in every minute. Please give me a solution for this…

  11. Pratyush says:

    How to schedule multiple job in sequential execution ?

Leave a Reply to manoj Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s