TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Schedule Using Quatz .NET
Mohini Shinde
Dec 13, 2016
5
k
0
4
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
Here, you will learn how to schedule using Quatz .NET.
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();
}
That's it. Now, when you execute this code, the function will work repeatedly on the scheduled time.
Next Recommended Reading
Push Notification Using Firebase Cloud Messaging Using .NET