I have created a windows service on VS.net C#
In the OnStart event I start a timer.
In side the timer I call a function called DO()
the process of the DO() function is very long ( takes more than hour)
The process suppose to go this way
Start Then call the time immediately but due to the timer interval need to wait another day
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart.");
try
{
Timer timer = new Timer();
timer.Interval = 1000 * 60 *60 * 24;
timer.Elapsed += new ElapsedEventHandler(this.OnTimer);
timer.Start();
DO();
}
catch (Exception ex)
{
eventLog1.WriteEntry("ERROR (OnStart) : " + ex.ToString());
}
}
public void OnTimer(object sender, ElapsedEventArgs args)
{
DO();
}
private void DO()
{
// Some process takes an hour
}
When the service starts it stays an hour in "Starting"
Is there a way I can start my service DO() function immediatly once the service started but not from the OnStart event?