|
-
Apr 25th, 2003, 05:47 AM
#1
Thread Starter
Member
Form_Load event
When opening a form, I am loading data into a few combo boxes from an Oracle database.
I make a call to a class that load the data from the Form_Load event.
The form hangs and is not fully drawn until my data fetching is complete.
I used to have this problem in VB but I used the .Show method then, at the begining of the Form_Load event to show the form before getting data from the database which solved that.
I tried this in C# but it doesn't seem to work.
Any idea's on how I can show the form fully and have the data load whilst it is shown.
-
Apr 25th, 2003, 02:40 PM
#2
You can load the data in a seperate thread.
Code:
using System.Threading;
// ....
class myForm : Form
{
public void LoadDatabase()
{
// ... do stuff
}
public void myForm_Load()
{
Thread t = new Thread(new ThreadStart(LoadDatabase) );
t.Start();
}
}
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Apr 25th, 2003, 06:03 PM
#3
yay gay
also, if u wanto to create controls in the form in that method, u cant as u have to create another method that does that job and u must call it as this.BeginInvoke(<delegate pointing to the method>, <args if any>); otherwise u'll get an error in the threads
\m/  \m/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|