[Mono-bugs] [Bug 79484][Nor] Changed - null reference exception in System.Timers.StartTimer()
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Tue Sep 26 04:00:23 EDT 2006
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by psingh at fnfr.com.
http://bugzilla.ximian.com/show_bug.cgi?id=79484
--- shadow/79484 2006-09-24 18:13:26.000000000 -0400
+++ shadow/79484.tmp.17557 2006-09-26 04:00:23.000000000 -0400
@@ -30,6 +30,35 @@
How often does this happen?
Very often - on one machine it happens 99% of the time, on another it
happens 50% of the time. I tried running our app with mono -v option to get
more information, but it prints mostly useless information about "emitting"
code.
+
+------- Additional Comments From psingh at fnfr.com 2006-09-26 04:00 -------
+We looked at the source code for System.Timers.Timer class and here is
+the problem. If Timer.AutoReset = false, the loop exits and sets wait
+= null. If the user has called Timer.Start() again, a new thread can
+get into the while condition after the previous thread has set the
+wait to null just after this new thread created new "wait" object. The
+fix can be simple.
+
+-Pawan
+
+void StartTimer ()
+ {
+ wait = new ManualResetEvent (false);
+
+ WaitCallback wc = new WaitCallback (Callback);
+ while (enabled && wait.WaitOne ((int)
+interval, false) == false) {
+ if (autoReset == false)
+ enabled = false;
+
+ ThreadPool.QueueUserWorkItem (wc, this);
+ }
+
+ wc = null;
+ ((IDisposable) wait).Dispose ();
+ ==> wait = null;
+ }
+
More information about the mono-bugs
mailing list