Subject: specifing the time intraval in win service
Posted By: srkarthik_82 Post Date: 1/8/2007 4:24:18 AM
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();
                //timer.Interval =Convert.ToDouble(System.Configuration.ConfigurationSettings.AppSettings.Get("JDEdTamesSynchronizer.TimerInterval"));            }
            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" );
        }


Go to topic 54505

Return to index page 71
Return to index page 70
Return to index page 69
Return to index page 68
Return to index page 67
Return to index page 66
Return to index page 65
Return to index page 64
Return to index page 63
Return to index page 62