tags:

views:

129

answers:

2

I am using a very component heavy form that takes long time to set up. Part of the set up is behaviour of third party controls, that I cannot gather progress on. (DevExpress XtraScheduler). This freezes the app.

What properties on the form do I need to set up so the forms loads in the background and what events should I contentrate on ?

EDIT:

I am aware of the BackgroundWorker, but If I push the creation of the form on the BW, how will I know when the process is done ? I mean, can I somehow let the form prepare itself (remember I am not in control of what the components are doing) and notify the BW that its done preparing ? What event would that be ?

+1  A: 

If it is the initial load of your application that takes time, you could consider adding a splash screen. If it is a secondary form, then the BackgroundWorker class is an excellent component allowing you to perform time consuming tasks on background threads without freezing your main GUI thread. The DoWork, ProgressChanged and RunWorkerCompleted events are particularly useful.

Darin Dimitrov
I clarified my question a bit. I need to know what events to ties BW to. Nice job with the links.
Tomas Pajonk
The RunWorkerCompleted event will be executed when the work is done. You mention that you are not in control of what the controls are doing but at some moment you are calling some function that takes time. It is this function you need to execute inside the DoWork handler.
Darin Dimitrov
+1  A: 

The VB.NET splash screen is perfect for just this. If you're working in C# you can import Microsoft.VisualBasic to get access to the same effect. Your main form loads in the background and the splash screen runs smoothly in the foreground for the duration.

Robert Venables