Block.st
branchjv
changeset 19238 aaf80a17225f
parent 18995 05e03473f406
parent 19237 666721759dbb
child 19478 1f5aa87f6170
--- a/Block.st	Wed Feb 17 07:03:44 2016 +0100
+++ b/Block.st	Thu Feb 18 07:01:58 2016 +0100
@@ -2295,29 +2295,34 @@
     "Modified: / 26.7.1999 / 11:24:06 / stefan"
 !
 
-valueWithTimeout:aTimeDuration
+valueWithTimeout:aTimeDurationOrIntegerSeconds
     "execute the receiver, but abort the evaluation after aTimeDuration if still running.
      Return the receiver's value, or nil if aborted."
 
-    ^ self valueWithWatchDog:[^ nil] afterMilliseconds:aTimeDuration asMilliseconds
+    |milliseconds|
+
+    milliseconds := aTimeDurationOrIntegerSeconds isTimeDuration
+                        ifTrue:[ aTimeDurationOrIntegerSeconds asMilliseconds ]
+                        ifFalse:[ (aTimeDurationOrIntegerSeconds * 1000) truncated].
+    ^ self valueWithWatchDog:[^ nil] afterMilliseconds:milliseconds
 
     "
      [
-	1 to:15 do:[:round |
-	    Transcript showCR:round.
-	    Delay waitForMilliseconds:20.
-	].
-	true
+        1 to:15 do:[:round |
+            Transcript showCR:round.
+            Delay waitForMilliseconds:20.
+        ].
+        true
      ] valueWithTimeout:(TimeDuration seconds:1)
     "
 
     "
      [
-	1 to:100 do:[:round |
-	    Transcript showCR:round.
-	    Delay waitForMilliseconds:20.
-	].
-	true
+        1 to:100 do:[:round |
+            Transcript showCR:round.
+            Delay waitForMilliseconds:20.
+        ].
+        true
      ] valueWithTimeout:(TimeDuration seconds:1)
     "
 !