Sleep doesn't work properly.

Kannan

Member
Joined
Feb 3, 2005
Messages
13
Location
India
Programming Experience
Beginner
This is my situation.
In a procedure,

I load a form which has around 5 text boxes and a grid.

Next I load a data into that grid with around 1000 records !

Then I load another form which has around 5 text boxes and a grid.

Next I load a data into that grid with around 1000 records !

Like wise I load 5 form and each has text boxes and grids.


My problem is that the form loads but that text boxes are not properly visible till the data is loaded.

I tried System.Threading.Thread.Sleep(2000) which gives a delay in between the form load and data loading.

i.e
Form1 Load
Delay for 2 sec
Load data

Form2 Load
Delay for 2 sec
Load data

Form3 Load
Delay for 2 sec
Load data

Form4 Load
Delay for 2 sec
Load data

Form5 Load
Delay for 2 sec
Load data

Still the text boxes are not visible properly till the data loads.


I tried both
System.Threading.Thread.Sleep(2000)
as well as
DeclareSub Sleep Lib "kernel32" (ByVal dwMilliseconds AsLong)
Sleep(2000)

Still they don't work.

Since I have 5 such forms which will load consecutively and load 1000's of record I don't like to use separate timer for all these operations.

I want one function which can be called from anywhere and can give a delay and then continue.

Thanks in Advance.
 
I'd like info on this too. Same problem. User clicks the start icon and nothing happens till the data loads (slow network!). The cursor doesn't even stay as the "wait" hourglass while loading. Any way to say put up the form first so I can display a wait message "Loading..."?
 
I have been 80 % successful :p

I used the Form.refresh() and it works.

So what I have done is...

VB.NET:
[size=2][color=magenta]FfrmMain[/color].[color=blue]Refresh()[/color][/size]
[size=2][color=sienna]System[/color].[color=darkorange]Threading.Thread[/color].[color=blue]Sleep([color=black]500[/color])[/color]
[/size]Then start loading the data.

And it works for me !!.:)
80 % of course :p
 
I fixed mine by moving the data loading from the form load event to the Activated event. I put up a lable "Loading..." on the form and then hide it when Activated ends. Makes the sleep time unneeded, I think. I guess you have to either make sure Activated only happens once or, use a "loaded" flag to control data loading.
 
Back
Top