Fix Task.Wait timeout regression
authorJérémie Laval <jeremie.laval@gmail.com>
Tue, 18 Jan 2011 15:59:27 +0000 (15:59 +0000)
committerJérémie Laval <jeremie.laval@gmail.com>
Tue, 18 Jan 2011 16:00:05 +0000 (16:00 +0000)
mcs/class/corlib/System.Threading.Tasks/ThreadWorker.cs

index 91a76472ceb941eb82a5ddea0160dd379c1824fb..85a85515b482d179c1300b853edf989928d2b278 100644 (file)
@@ -245,6 +245,8 @@ namespace System.Threading.Tasks
                        int tries = 8;
                        WaitHandle[] handles = null;
                        Watch watch = Watch.StartNew ();
+                       if (millisecondsTimeout == -1)
+                               millisecondsTimeout = int.MaxValue;
 
                        while (!predicateEvt.IsSet && watch.ElapsedMilliseconds < millisecondsTimeout) {
                                Task value;
@@ -349,7 +351,7 @@ namespace System.Threading.Tasks
 
                static int ComputeTimeout (int proposed, int timeout, Watch watch)
                {
-                       return timeout == -1 ? proposed : System.Math.Min (proposed, System.Math.Max (0, (int)(timeout - watch.ElapsedMilliseconds)));
+                       return timeout == int.MaxValue ? proposed : System.Math.Min (proposed, System.Math.Max (0, (int)(timeout - watch.ElapsedMilliseconds)));
                }
                
                public bool Finished {