load data from database asyc while UI loads...

  • Thread starter Thread starter Smokey Grindel
  • Start date Start date
S

Smokey Grindel

How would I go about doing this? I know it has to do with threading but not
sure how to code this to do something like this...

I have a form which is complex... but I need to load data async while the
form displays with out stoping the form from rendering (right now there is a
2 second pause)

I want to when the form opens load the form and in parallel start to pull
data from the database (about 2,000 records) and while that is going on have
the mouse cursor has a wait cursor then when its down populate the form's
data on screen and change the cursor back... and suggestions or examples on
how to do something like this? thanks!
 
[...]
I have a form which is complex... but I need to load data async while the
form displays with out stoping the form from rendering (right now there
is a
2 second pause)

The usual solution is to execute the time-consuming operation using the
BackgroundWorker class. It provides progress and completion events that
intrinsically handle the cross-thread issues for you when updating the UI
as the operation progresses.

You can set the cursor displayed when the cursor is over your
application's form by using the Cursor property of the form. See also
Cursors.WaitCursor.

Pete
 
Also, depending on the provider, you might have asynchronous methods on
the connection itself which allow for asynchronous calls.

If you have a large number of calls that need to be made, then doing it
all on one thread with a BackgroundWorker will be better, since you can
encapsulate all of the calls in one place, but if you have just one query to
execute, then you should consider the asynchronous methods if your provider
provides it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Peter Duniho said:
[...]
I have a form which is complex... but I need to load data async while the
form displays with out stoping the form from rendering (right now there
is a
2 second pause)

The usual solution is to execute the time-consuming operation using the
BackgroundWorker class. It provides progress and completion events that
intrinsically handle the cross-thread issues for you when updating the UI
as the operation progresses.

You can set the cursor displayed when the cursor is over your
application's form by using the Cursor property of the form. See also
Cursors.WaitCursor.

Pete
 
Back
Top