Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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
Developer Community or GitHub 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.
System.NullReferenceException: Object reference not set to an instance of an object
at System.Timers.Timer.set_Enabled (Boolean value) <0x10153e870 + 0x00080> in <filename unknown>:0 (code.cs:1)
at System.Timers.Timer.Start () <0x10153edd8 + 0x0000f> in <filename unknown>:0 (code.cs:1)
Have no repro, and have no time to prepare it. It is a rare race condition bug.
There is no such bug in .NET version of our game. Bug is mono impl specific.
According to the documentation (https://msdn.microsoft.com/en-us/library/system.timers.timer(v=vs.100).aspx#Anchor_10), "Any instance members are not guaranteed to be thread safe.". And, as you reported, your case involve multiple threads accessing the Timer instance method, so it is then in clear violation of the API / Documentation.
Moreover, we imported System.Timers.Timer from referencesource (https://github.com/mono/mono/commit/02782f4a1ad12eb30bf7e55ad091b3643bd50a3a), meaning it's the same implementation as on .NET.
Thank you for your report,
Have a great day,