specifing the time intraval in win service
Hi guys,
I want to set the intraval time as 24hours i.e only once per day i shud run my windows service to perform the task.Moreover i have coded to start my service after one minute of log on and now i have to set the time to run the task.I am struck in specifing the time.
Please look at the underlined line of the code and suggest me how to do it.
Thanks for ur kindness,
Karthik
public void OnTimedEvent(object source, ElapsedEventArgs e)
{
AddEventLog( "Buildfolio Services entered" );
try
{
if( timer!=null )
timer.Stop();
foreach( IService s in subServices )
{
try
{
s.TimedEvent();
}
catch( Exception ex )
{
AddEventLog( "Sub Service: Exception "+ex.Message );
}
}
RootSystem.timeCount++;
if( timer!=null )
timer.Start();
[u]//timer.Interval =Convert.ToDouble(System.Configuration.Configurati onSettings.AppSettings.Get("JDEdTamesSynchronizer. TimerInterval"));</u> }
catch( Exception ex )
{
AddEventLog( "AMOS Services: Exception "+ex.Message );
}
AddEventLog( "AMOS Services exited" );
}
/// <summary>
/// Set things in motion so your service can do its work.
/// </summary>
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
try
{
timer = new System.Timers.Timer();
timer.Elapsed += new ElapsedEventHandler( OnTimedEvent );
timer.Interval = 60000;
timer.Enabled=true;
}
catch( Exception ex )
{
AddEventLog( ex.Message );
}
AddEventLog( "AMOS Services started" );
}
__________________
Karthik
[Nothing is impossible]
|