System.Threading.Timer.Change C# (CSharp) Method

Change() public method

public Change ( System dueTime, System period ) : bool
dueTime System
period System
return bool
        public bool Change(System.TimeSpan dueTime, System.TimeSpan period)
        {
            throw null;
        }

Same methods

Timer::Change ( int dueTime, int period ) : bool
Timer::Change ( long dueTime, long period ) : bool
Timer::Change ( uint dueTime, uint period ) : bool

Usage Example

        public MFTestResults TimerTest0()
        {
            MFTestResults result = MFTestResults.Pass;
            try
            {
                timerEvent.Reset();
                /// Save the current time shifted by 5 hours.
                
                timerTime = DateTime.UtcNow - utcTimeShiftAmount;
                using (Timer t = new Timer(new TimerCallback(TimerCallback), null, new TimeSpan(0, 0, 30), new TimeSpan(-TimeSpan.TicksPerMillisecond)))
                {
                    /// We shift the utc back by 5 hours.
                    TimeService.SetUtcTime(timerTime.Ticks); 
                    
                    /// timer should still fire after 30 seconds even though absolute time has been manipulated.
                    if (!timerEvent.WaitOne(2 * 60 * 1000, false))
                    {
                        result = MFTestResults.Fail;
                    }

                    /// Reset the changes.
                    TimeService.SetUtcTime((DateTime.UtcNow + utcTimeShiftAmount).Ticks);

                    t.Change(-1, -1);
                }
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected exception", ex);
                result = MFTestResults.Fail;
            }

            return result;
        }
All Usage Examples Of System.Threading.Timer::Change