C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Schedule Using Quatz .NET
WhatsApp
Mohini Shinde
8y
5.1
k
0
4
25
Blog
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.
Recommended related topics
Membership not found