Example #1
0
        /// <summary>
        /// Changes the start time and the interval between method invocations for a timer, using 32-bit signed integers to measure time intervals.
        /// </summary>
        /// <param name="p_delay">The amount of time to delay before callback is invoked, in milliseconds.</param>
        /// <param name="p_period">The time interval between invocations of callback, in milliseconds.</param>
        public void Change(int p_delay, int p_period)
        {
            TimedTask task = ForegroundProcessor.GetTimedTask(m_timedTaskKey);

            task.Delay     = p_delay;
            task.Interval  = p_period;
            task.LoopTimes = 0;
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the Timer class, and sets the Interval property to the specified number of milliseconds.
 /// </summary>
 public ForegroudTimer(int p_interval)
 {
     m_timedTaskKey = ForegroundProcessor.AppendAction(() =>
     {
         if (ElapsedEvent != null)
         {
             ElapsedEvent(this, new ElapsedEventArgs());
         }
     }, p_interval, -1, 0);
     ForegroundProcessor.GetTimedTask(m_timedTaskKey).IsEnabled = false;
 }
Example #3
0
 /// <summary>
 /// Releases all resources used by the current instance of Timer and signals when the timer has been disposed of.
 /// </summary>
 public void Dispose()
 {
     ForegroundProcessor.CancelAction(m_timedTaskKey);
 }
Example #4
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="p_callback">A TimerCallback delegate representing a method to be executed.</param>
 /// <param name="p_state">An object containing information to be used by the callback method, or null.</param>
 /// <param name="p_delay">The amount of time to delay before callback is invoked, in milliseconds.</param>
 /// <param name="p_period">The time interval between invocations of callback, in milliseconds.</param>
 public ForegroudTimer(TimerCallback p_callback, object p_state, int p_delay, int p_period)
 {
     m_callback     = p_callback;
     m_state        = p_state;
     m_timedTaskKey = ForegroundProcessor.AppendAction(() => m_callback(m_state), p_period, -1, p_delay);
 }
Example #5
0
 /// <summary>
 /// Stops raising the Elapsed event by setting Enabled to false.
 /// </summary>
 public void Stop()
 {
     ForegroundProcessor.GetTimedTask(m_timedTaskKey).IsEnabled = false;
 }
Example #6
0
 /// <summary>
 /// Starts raising the Elapsed event by setting Enabled to true.
 /// </summary>
 public void Start()
 {
     ForegroundProcessor.GetTimedTask(m_timedTaskKey).IsEnabled = true;
 }