Jelajahi Sumber

2003-06-21 Gonzalo Paniagua Javier <[email protected]>

	* ThreadPool.cs: correctly create a TimeSpan with provided the number of
	milliseconds.

	* WaitHandle.cs: fixes for WaitAny/All and TimeSpan.

svn path=/trunk/mcs/; revision=15535
Gonzalo Paniagua Javier 22 tahun lalu
induk
melakukan
89a8bd709d

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

@@ -1,3 +1,9 @@
+2003-06-21  Gonzalo Paniagua Javier <[email protected]>
+
+	* ThreadPool.cs: correctly create a TimeSpan with provided the number of
+	milliseconds.
+
+	* WaitHandle.cs: fixes for WaitAny/All and TimeSpan.
 
 2003-06-06  Gonzalo Paniagua Javier <[email protected]>
 

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

@@ -208,7 +208,7 @@ namespace System.Threading {
 			if (ms < -1)
 				throw new ArgumentOutOfRangeException ("millisecondsTimeOutInterval", "timeout < -1");
 
-			return new TimeSpan (ms);
+			return new TimeSpan (0, 0, 0, 0, (int) ms);
 		}
 
 		public static RegisteredWaitHandle RegisterWaitForSingleObject (WaitHandle waitObject,

+ 13 - 10
mcs/class/corlib/System.Threading/WaitHandle.cs

@@ -52,12 +52,12 @@ namespace System.Threading
 					   bool exitContext)
 		{
 			CheckArray (waitHandles);
-			int ms=Convert.ToInt32(timeout.TotalMilliseconds);
+			long ms = (long) timeout.TotalMilliseconds;
 			
-			if(ms < 0 || ms > Int32.MaxValue)
-				throw new ArgumentOutOfRangeException("Timeout out of range");
+			if (ms < -1 || ms > Int32.MaxValue)
+				throw new ArgumentOutOfRangeException ("timeout");
 
-			return(WaitAll_internal(waitHandles, ms, exitContext));
+			return (WaitAll_internal (waitHandles, (int) ms, exitContext));
 		}
 
 		[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -82,12 +82,12 @@ namespace System.Threading
 					  TimeSpan timeout, bool exitContext)
 		{
 			CheckArray (waitHandles);
-			int ms=Convert.ToInt32(timeout.TotalMilliseconds);
+			long ms = (long) timeout.TotalMilliseconds;
 			
-			if(ms < 0 || ms > Int32.MaxValue)
-				throw new ArgumentOutOfRangeException("Timeout out of range");
+			if (ms < -1 || ms > Int32.MaxValue)
+				throw new ArgumentOutOfRangeException ("timeout");
 
-			return(WaitAny_internal(waitHandles, ms, exitContext));
+			return (WaitAny_internal(waitHandles, (int) ms, exitContext));
 		}
 
 		[MonoTODO]
@@ -137,9 +137,12 @@ namespace System.Threading
 
 		public virtual bool WaitOne(TimeSpan timeout, bool exitContext)
 		{
-			int ms=Convert.ToInt32 (timeout.TotalMilliseconds);
 			CheckDisposed ();
-			return(WaitOne_internal(os_handle, ms, exitContext));
+			long ms = (long) timeout.TotalMilliseconds;
+			if (ms < -1 || ms > Int32.MaxValue)
+				throw new ArgumentOutOfRangeException ("timeout");
+
+			return (WaitOne_internal(os_handle, (int) ms, exitContext));
 		}
 
 		protected static readonly IntPtr InvalidHandle = IntPtr.Zero;