Re: How to simulate Thread.sleep in GWT?

2012-01-24 Thread Jim Douglas
There's really no good answer.  JavaScript isn't multi-threaded, so
there's no way to do anything like Java's Thread.sleep().  Since
there's no real equivalent, the answer always boils down to what
precisely are you trying to accomplish?  You can try reviewing what
other people have suggested:

http://www.google.com/search?q=javascript+sleep
http://www.google.com/search?q=gwt+thread.sleep

On Jan 24, 12:49 pm, laredotornado laredotorn...@zipmail.com wrote:
 Hi,

 I'm using GWT 2.4 and writing some test cases uses GwtTestCase.  I
 want to stall my program for a few seconds at certain points, but the
 only way I've seen to do this (using a Timer) is not addressing my
 needs.  How do I pause my program for a certain number of seconds?

 ps - The Timer function is not what I want because all commands after
 the Timer's schedule command continue to run.  Execution is
 interrupted only when the timer goes off.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: How to simulate Thread.sleep in GWT?

2012-01-24 Thread Colin Alworth
GwtTestCase has support for waiting until an asynchronous part of the test 
is complete - check out the delayTestFinish(int) and finishTest() methods.

Beyond that, there really is no way to generally pause execution. You can 
use one timer to watch another timer, and call cancel on it if it runs for 
too long, though because JavaScript is singly threaded, you can't cancel 
something already in progress. For that, you want to break up your command 
into smaller pieces (using something like the Scheduler and 
RepeatingCommand).

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/jaytlhEKO-0J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: How to simulate Thread.sleep in GWT?

2012-01-24 Thread objectuser
Could you just have the final part of the test *be* the firing of the timer?

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/iMANGW2SapgJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.