:::: MENU ::::

Scheduled Tasks in Asp.Net with Quartz.Net

In this post i will show you how to create a scheduled tasks easily with Quartz.Net library.As a first step we will create  an empty asp.net web application.

We can manually download quartz library dll and add as a reference or we can use nuget package manager to install necessary files. You can open nuget package manager console like below image.


Package manager console is very helpful to manage packages and we just need to type “Install-Package Quartz” and hit enter to download necessary dll files, when you see message like “Successfully installed ‘Quartz” that means dll files are downloaded and added as a reference to your project.

Now we have Quartz.Net but how we will implement this library to our project?

Answer is very easy because we just need to implement “IJob” Interface’s  Execute method in our class.

I am personally using Quartz for sending push notification to my mobile apps, basically quartz runs every hour and checks database for news,  if there is something new then system sends a push notification to mobile devices.

Quartz working very well on this process. 🙂

In above scenerio i’ve created a Push class with below code

As you can see in above code , Push class inherited from IJob interface and implementing Execute method of interface. We wrote our codes in execute method to run when task executed but we didn’t do  anything about task settings therefore i’ve created JobScheduler class  to set task settings with following codes.

At above code we said to quartz , we want  tasks to start now , repeat every 10 second to  forever, you can use your own settings to configure your tasks.

As last step , we will add a global.asax file to start Quartz in Application_Start method like below codes

Finally we are done. You can change execute method and test in your machine.

You can find source code here : https://github.com/hamdiceylan/QuartzNetScheduledTask

I hope quartz helps you on your projects ,see you on next tutorial.




One Comment

  • Reply NMQuan |

    Nice article… I did as instruct and when I deploy the project to IIS, it does not work. Please help me!!!!

So, what do you think ?