I'm looking for solution to the following issue: I have a website and want that every one hour (approximately) will send mail to some address. So I decided to use Quartz library for C#. I wrote The job, the Start() function and the Execute:
public static void Start()
{
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
scheduler.Start();
IJobDetail job = JobBuilder.Create<EmailJob>().Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInMinutes(50)
.RepeatForever())
.Build();
scheduler.ScheduleJob(job, trigger);
}
In the Application_start():
JobScheduler.Start();
When I run the website locally it works perfect, because the application is in "Play" mode all the time. so it's send the mail every 50 minutes as expected.
Now for the problem: When upload the website to the server, Job worked only one time - in the first time. After I read about it, my conclusion for this problem is that the website application have a "sleep" mode so if someone is not enter to the website, the application is sleep so the job is not working and the email doesn't sent.
So My question is - What can I do if I want a scheduler that will run function every 50 minutes, and not depend if someone entered the website or not?