0

I am using from quartz dll to do some jobs in a specific time plan. I run the schedules in application_start in Global file. It works for me good in the local but when I publish the project it doesn't work. For publishing the project I just copy and overwrite the bin and views folder. The proper Global file that contains the running codes exist in the server. Should I publish it again or what to do?

What should I do?

Hamid Reza
  • 2,913
  • 9
  • 49
  • 76
  • I don't know Quartz.NET too well, but when your `Application Pool` recycles, `application_start` is called again, and maybe that is messing with your scheduling. – Elad Lachmi Dec 08 '13 at 07:33
  • So you mean I should restart the iis too call the application_start again? – Hamid Reza Dec 08 '13 at 07:40
  • I mean that if you schedule something, and then IIS recycles your application before the task is run, it will schedule it again and then IIS will recycle the pool again, so your task is never actually run. – Elad Lachmi Dec 08 '13 at 08:17
  • I got it. IIS recycled my website when the task was not running and I added the task codes later. Now what is the solution? I restarted my IIS. should it work or JUST changing the web.config would solve it? – Hamid Reza Dec 08 '13 at 08:21
  • You should make the schedule time shorter than the recycle period, or make the recycle period longer than the schedule period. In general, web applications are not a good place to schedule tasks, since they are restarted automatically by IIS in set intervals and also at unknown times when memory consumption is too high or when a set number of requests have been filled. – Elad Lachmi Dec 08 '13 at 11:02

1 Answers1

1

IIS normally doesn't start your application until it has to, ie. someone views a page, and it stops your application after a certain amount if idling, or whenever it feels like it really. You can even configure IIS to run your app in any number of concurrent worker processes. So webapps are not suitable for background jobs, windows services are.

But as a workaround, you can configure your app to run constantly: http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx

fejesjoco
  • 11,763
  • 3
  • 35
  • 65
  • I did some researches to select windows services or something like quartz and I think that it depends on the work that we want to do with it.In my case quartz could solve my problem but do you think that restarting the iis would result in calling again tha application_start? – Hamid Reza Dec 08 '13 at 08:07
  • If you make the changes described in that link, then your application will always be running, but not with Application_Start, you need to write an auto-start provider instead. Application_Start is only called when a request comes in, AFAIK. – fejesjoco Dec 08 '13 at 08:43