Jeff,
There are many ways to accomplish this with a form in VB including
threading, asynchronous delegates and DoEvents() (note that these techniques
should apply to all dotnet languages, not just VB). The difference is that
windows forms in dotnet add a layer to insulate the developer from having to
deal with the low-down windows events (although you can still get at them
with the WndProc method or API calls).
Events in .NET have nothing to do with the windows message queue events,
instead their implementation is based on multicast delegates (synchronous
ones) and are a managed part of the dotnet framework. Because these
delegates are synchronous, there is no messsage queue for them and you can't
post a message to the bottom of the queue.
If you want your form to be shown fully before populating the loading of the
data, then try the following:
-------------------------------
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
' Call the Base Method
MyBase.OnLoad(e)
' Allow the window to process all its waiting windows messages
Application.DoEvents()
' Do stuff to load the data
End Sub
--------------------------------
Note that with the above example, your form should paint OK with the call to
DoEvents, but it will still not respond to user messages while loading the
data (unless you call doevents while loading the data, or use a thread to
load the data).
If you are loading a lot of data, then I would suggest using a thread.
They're not that hard to do in .net as long as you are careful when calling
a method on the form or one of its controls.
Hope this helps,
Trev.
Jeff Casbeer said:
Thanks again for responding Trev. My background is with Powerbuilder, but
I've done this in other languages as well. We load the window before
beginning the slower process of retrieving data, or the non-visual processes
of creating business objects, etc. In other words, anything that isn't
related to the user interface directly gets deferred until the form has
completed drawing. We do this with a custom windows event. We set up a
custom event on the form and then "post" the event. Posting the event tells
Windows to stick the event at the bottom of the message queue rather than
the top. (Raiseevent seems to use window's "send" functionality, which runs
the event *right now*.) The effect is that the form displays first, faster,
before all other processing occurs, resulting in better perceived
performance.