about Sleep

overbrain

New member
Joined
Apr 17, 2007
Messages
1
Programming Experience
Beginner
Hello..

When I used Sleep method in VB.NET, I thought it would be waited .
But I would not.

for example.

1. 1st Procedure
2. thread.sleep(3000)
3. 2nd Procedure

In this case, When I start program, first it wait 3sec , and then operate procedure 1st and 2nd.

What's wrong with it.

please answer me.

JRoh
 
What happened in your example was:
1. 1st Procedure was done.
2. thread stopped for 3 seconds (probably your UI/application thread?)
3. 2nd Procedure was done.

Depending on what you are waiting for thread.sleep could be used for waiting (but not for long on UI thread! not 3 seconds!). If it's waiting for something in application or after application event you cannot sleep the UI thread to wait, it will only stop/freeze it.
 
Back
Top