New to Quartz but it seems powerful and I want to use it in my asp.net
applications. So far I've added this to my Application_Start and the
class and I'm trying to have it run every two minutes but nothing is
happening. Figured I missed something.
protected void Application_Start(object sender, EventArgs e)
{
// construct a scheduler factory
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
IScheduler sched = schedFact.GetScheduler();
// construct job info
JobDetail jobDetail = new JobDetail("myJob", null, typeof
(IMAutoJob));
// fire every hour
Trigger trigger = TriggerUtils.MakeMinutelyTrigger(2);
// start on the next even hour
trigger.StartTimeUtc = TriggerUtils.GetEvenHourDate
(DateTime.UtcNow);
trigger.Name = "myTrigger";
sched.ScheduleJob(jobDetail, trigger);
sched.Start();
}
And I've added this class to the App_Code Folder
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Quartz;
/// <summary>
/// Summary description for IMAutoJob
/// </summary>
public class IMAutoJob : IJob
{
public IMAutoJob()
{
}
#region IJob Members
public void Execute(JobExecutionContext context)
{
IM.RunUpdate();
}
#endregion
}
--
You received this message because you are subscribed to the Google Groups "Quartz.NET" group.
To post to this group, send email to quar...@googlegroups.com.
To unsubscribe from this group, send email to quartznet+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/quartznet?hl=en.
And again I would advice to have a different process to handle job
scheduling (Windows services).
-Marko
Having said that what marko points out is the issue. The scheduler
instance is getting GC.
--
Thanks,
Swami
On Dec 30, 3:16 pm, Marko Lahma <marko.la...@gmail.com> wrote:
> You should at least keep an instance of the scheduler factory around.
> Now it's just visible until the end of application start method and
> after that it'll be presumably eligible to garbage collection. So what
> if you try with having a "private static ISchedulerFactory schedFact"
> as a field?
>
> And again I would advice to have a different process to handle job
> scheduling (Windows services).
>
> -Marko
>
private static ISchedulerFactory schedFact = new StdSchedulerFactory
();
protected void Application_Start(object sender, EventArgs e)
{
// construct a scheduler factory
//ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
IScheduler sched = schedFact.GetScheduler();
// construct job info
JobDetail jobDetail = new JobDetail("myJob", null, typeof
(IMAutoJob));
// fire every hour
Trigger trigger = TriggerUtils.MakeMinutelyTrigger(2);
// start on the next even hour
trigger.StartTimeUtc = TriggerUtils.GetEvenHourDate
(DateTime.UtcNow);
trigger.Name = "myTrigger";
sched.ScheduleJob(jobDetail, trigger);
sched.Start();
}
And still nothing is happening.
On Dec 30, 4:32 pm, Swami Iyer <onlyone.swamii...@gmail.com> wrote:
> IMHO, It is a bad idea to do this ASP.NET code. Because you have to
> make sure that the IIS lifecycle does not destroy this application
> from the app pool when it is idle. (not getting http request).
>
> Having said that what marko points out is the issue. The scheduler
> instance is getting GC.
>
>
>
> On Wed, Dec 30, 2009 at 4:16 PM, Marko Lahma <marko.la...@gmail.com> wrote:
> > You should at least keep an instance of the scheduler factory around.
> > Now it's just visible until the end of application start method and
> > after that it'll be presumably eligible to garbage collection. So what
> > if you try with having a "private static ISchedulerFactory schedFact"
> > as a field?
>
> > And again I would advice to have a different process to handle job
> > scheduling (Windows services).
>
> > -Marko
>
> >> For more options, visit this group athttp://groups.google.com/group/quartznet?hl=en.