Explorar o código

2004-05-11 Gonzalo Paniagua Javier <[email protected]>

	* Timer.cs: if AutoReset, disable the timer before adding the callback
	to the ThreadPool. Patch by Tim Fries <[email protected]>. Fixes bug
	#57993.

svn path=/trunk/mcs/; revision=27114
Gonzalo Paniagua Javier %!s(int64=22) %!d(string=hai) anos
pai
achega
ec3393747f

+ 6 - 0
mcs/class/System/System.Timers/ChangeLog

@@ -1,3 +1,9 @@
+2004-05-11  Gonzalo Paniagua Javier <[email protected]>
+
+	* Timer.cs: if AutoReset, disable the timer before adding the callback
+	to the ThreadPool. Patch by Tim Fries <[email protected]>. Fixes bug
+	#57993.
+
 2003-03-17  Gonzalo Paniagua Javier <[email protected]>
 
 	* Timer.cs: Elapsed is an event. Added a few attributes.

+ 5 - 4
mcs/class/System/System.Timers/Timer.cs

@@ -136,9 +136,6 @@ namespace System.Timers
 		static void Callback (object state)
 		{
 			Timer timer = (Timer) state;
-			if (timer.autoReset == false)
-				timer.enabled = false;
-
 			if (timer.Elapsed == null)
 				return;
 
@@ -156,8 +153,12 @@ namespace System.Timers
 			wait = new ManualResetEvent (false);
 
 			WaitCallback wc = new WaitCallback (Callback);
-			while (enabled && wait.WaitOne ((int) interval, false) == false)
+			while (enabled && wait.WaitOne ((int) interval, false) == false) {
+				if (autoReset == false)
+					enabled = false;
+
 				ThreadPool.QueueUserWorkItem (wc, this);
+			}
 			
 			wc = null;
 			((IDisposable) wait).Dispose ();