Parcourir la source

2007-09-14 Jb Evain <[email protected]>

	* Makefile: force the use of the 2.0 mscorlib to compile
	the 2.1 mscorlib.dll.


svn path=/trunk/mcs/; revision=89215
Paolo Molaro il y a 18 ans
Parent
commit
10f5121f53

+ 6 - 0
mcs/class/corlib/System.Threading/ChangeLog

@@ -1,3 +1,9 @@
+
+Thu Nov 8 18:36:25 CET 2007 Paolo Molaro <[email protected]>
+
+	* Timer.cs: if period is 0 with a non-infinite due time, we
+	run the callback just once (bug #340212).
+
 2007-10-24  Dick Porter  <[email protected]>
 
 	* Thread.cs: Call Thread_init on the new 2.0 constructors too.

+ 1 - 1
mcs/class/corlib/System.Threading/Timer.cs

@@ -81,7 +81,7 @@ namespace System.Threading
 						Timer t1 = entry.Value as Timer;
 						if (t1.next_run <= ticks) {
 							ThreadPool.QueueUserWorkItem (new WaitCallback (t1.callback), t1.state);
-							if (t1.period_ms == -1) {
+							if (t1.period_ms == -1 || ((t1.period_ms == 0 | t1.period_ms == Timeout.Infinite) && t1.due_time_ms != Timeout.Infinite)) {
 								t1.next_run = long.MaxValue;
 								if (expired == null)
 									expired = new ArrayList ();

+ 2 - 8
mcs/class/corlib/Test/System.Threading/TimerTest.cs

@@ -174,16 +174,10 @@ namespace MonoTests.System.Threading {
 		public void TestDelayZeroPeriodZero() {
 			Bucket b = new Bucket();
 			Timer t = new Timer(new TimerCallback(Callback),b,0,0);
-			/* we need to guess how many times the callback is invoked 
-			 * repeatedly in any given amount of time: this depends on cpu
-			 * speed, schedule decisions, system load etc. so the numbers 
-			 * are quite relaxed and we assume success if it executed 
-			 * 50 times in less than 100 ms.
-			 */
 			Thread.Sleep(100);
-			//stop the timer
 			t.Change (int.MaxValue, Timeout.Infinite);
-			Assert.IsTrue(b.count > 50);
+			// since period is 0 the callback should happen once (bug #340212)
+			Assert.IsTrue(b.count == 1);
 			
 		}