Bug 22881 - Setting System.Timers.Timer.Interval Property Does not Restart the Timer
Summary: Setting System.Timers.Timer.Interval Property Does not Restart the Timer
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-09-11 14:08 UTC by gullett.16
Modified: 2014-09-12 03:51 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description gullett.16 2014-09-11 14:08:06 UTC
In the MSDN documentation for the System.Timers.Timer.Interval property (found here: http://msdn.microsoft.com/en-us/library/system.timers.timer.interval%28v=vs.110%29.aspx), it states that:

"If Enabled and AutoReset are both set to false, and the timer has previously been enabled, setting the Interval property causes the Elapsed event to be raised once, as if the Enabled property had been set to true."

On Windows, code that utilizes this behavior works as expected.  However, on Mono 3.2.6, setting the Interval property does not re-enable the timer.  This issue can be reproduced with the following:

// Timer Member
private readonly System.Timers.Timer _timer = new System.Timers.Timer();

// Within the class constructor
_timer.AutoReset = false;
_timer.Elapsed += _timer_Elapsed;
_timer.Interval = 1000;

// _timer_Elapsed Member
private void _timer_Elapsed(object sender, ElapsedEventArgs e) {
    // This code is only executed once, although it should be executed once per second
    Console.Write("Timer Event Fired");
    _timer.Interval = 1000;
Comment 1 Marek Safar 2014-09-12 03:51:31 UTC
Please re-test with Mono 3.10 very similar issue has been fixed.