473,394 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problems starting a scheduler from Application_Start()

Hi,

While I realise that this may not be a very nice solution architecturally, I
kick off a Scheduler in an ASP.NET 2.0 webservice in Application_Start()
which is supposed to call a stored proc in a database once a day every day.

The code works on the day that the webservice is deployed, but not on
subsequent days unless I restart IIS.

The code looks like this:

void Application_Start(object sender, EventArgs e)
{

Scheduler sch = new Scheduler();

}

public Scheduler()
{
Logger.Write("Initialising scheduler.... " + DateTime.Now,
"ABSPerformance");
System.Timers.Timer testTimer = new System.Timers.Timer();
testTimer.Enabled = true;
testTimer.Interval = 60 * 1000;

testTimer.Elapsed += new
System.Timers.ElapsedEventHandler(testTimer_Elapse d);

}

private void testTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
if (!DateTime.Now.DayOfWeek.Equals(DayOfWeek.Saturday ) &&
!DateTime.Now.DayOfWeek.Equals(DayOfWeek.Sunday))
{

if (DateTime.Now.Hour.Equals(8) &&
DateTime.Now.Minute.Equals(30))
{
ABSData.executeNonQuery("StructuredCD.sp_ABS_Updat e",
null);
}

}

}

Is there a technical reason why I can't use the scheduler in this way, why
it only works on the first day?

As you have probably guessed, I am new to ASP.NET, so any help would be
appreciated.

Many thanks

Rob


Feb 25 '08 #1
1 1871
"austirob" <au******@discussions.microsoft.comwrote in message
news:81**********************************@microsof t.com...
Hi,

While I realise that this may not be a very nice solution architecturally,
I
kick off a Scheduler in an ASP.NET 2.0 webservice in Application_Start()
which is supposed to call a stored proc in a database once a day every
day.
You should probably let the database execute the stored proc once a day.
Alternatively, write a small console app to run it, and use the Windows Task
Scheduler to cause it to run periodically. This usage has nothing to do with
web services, which are not meant for anything like this!

I wouldn't be surprised to see your sch and testTimer objects being garbage
collected.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer
Feb 25 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jørn A. | last post by:
I'm working on a web based user interface for a job scheduling system (running scripts). The system is using a non-windows scheduler software, but it's installed and running as a windows...
6
by: Ober | last post by:
I'm having trouble with my security model, Application_Start, and accessing my database. My ASP.NET app is only going to be running in an intranet environment (not on the public Internet). ...
3
by: msnews.microsoft.com | last post by:
Hi What can you do with the errors occuring in global.asax in Application_Start (or Init) ? What is the best practice here ? What's the elegant solution in this case ? For now (I'm learning)...
0
by: SeanGallavan | last post by:
Our Environment: Two network load balanced (using Microsoft NLB software) webservers with session maintained in a SQL Server database. NLB is configured with no affinity settings and two...
6
by: Leslie | last post by:
I am attempting to handle errors by using Application_Error. This seems to work fine in most situations. However, if the exception occurs during the Application_Start method, the stand error...
8
by: bryan | last post by:
Is there any way I can get the application path (the one returned by Request.ApplicationPath) in the Application_Start method in Global.asax? Request is not valid there. On a related note, is there...
0
by: kapcreations | last post by:
I have a system tray app which gets the status of a windows service, and displays the appropriate icon for the status of the service in the systray. the problem I am having is the icon disapears...
4
by: Phil Mc | last post by:
Say for example you have a application running on a windows 2003 server (that is on server, not from). This application needs to start child applications (must be stand alone console applications),...
2
by: Cramer | last post by:
Is there some way - perhaps in Application_Start - that I can prevent an ASP.NET (3.5) application from starting. I would like to perform some environment validation and pipeline configuration...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.