コード例 #1
0
ファイル: Schedular.cs プロジェクト: lkajan83/MethodHiding
 private void InitializeTimer(double timeInterval)
 {
     if (timeInterval > 0)
     {
         ServiceTimer.Dispose();
         ServiceTimer          = new Timer();
         ServiceTimer.Enabled  = true;
         ServiceTimer.Elapsed += new ElapsedEventHandler(timer1_Tick);
         ServiceTimer.Interval = 10000;
     }
 }
コード例 #2
0
        /// <summary>
        /// The method that will be executed when the service is stopped.  This method
        /// disposes of the <see cref="ServiceTimer"/>. The <see cref="OnStop"/>
        /// abstract method will also be called if the service requires additional functionality
        /// on stopping. This method will catch and log any exceptions that occur on stopping.
        /// </summary>
        public void Stop()
        {
            try
            {
                Log.Info("Stopping periodic service.");
                if (ServiceTimer != null)
                {
                    ServiceTimer.Dispose();
                }

                OnStop();
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("An error occured while stopping the service: \n{0}", ex);
            }
        }
コード例 #3
0
ファイル: Service1.cs プロジェクト: Thokar/GoIPDynDnsClient
 protected override void OnStop()
 {
     ServiceTimer.Enabled = false;
     ServiceTimer.Dispose();
     ServiceTimer = null;
 }