Hi,
i'm developping an application for pocket PC using VS 2005 Beta2 and here is (are ) my problem(s )
I set up the first page as, let's say, "loading", once I launch the application, I want to first of all check if a login is set, if it is, show the login form ("login") and if not, load all the controls on my loading form, once they're all displayed, load the data from my database to finally show the welcome page ("welcome")
now, here's my method (all of them are into the "loading" form):
in the sub new() : check if the login is set, if it is, show "login" in dialog mode if not or if the login is correct, exit the sub new()
in the sub loading_load() : load all of the data from the database then show "welcome"
Now, here's the trick : "loading" only shows after all the data have been loaded, even if "welcome" is visible, it's hidden by "loading", got it I know why it doesn't work : "loading" hasn't called its show method while "welcome" already did. So : How can I at first load all the controls in "loading" before reading my database then show the "welcome" form without it loosing focus
One last thing : i tried to use the sub loading_activated method, but "loading" always feels like it's being activated.

loading controls and using load, activated and sub new()
bfellner
C#
Thread t = new Thread(new ThreadStart(this.InitializeForms));
t.Start();
t = new Thread(new ThreadStart(this.StartProgressBar));
t.Start();
VB
Dim t as New Thread(New ThreadStart(Me.InitializeForms))
t.Start()
t = New Thread(New ThreadStart(Me.StartProgressBar))
t.Start()
This will run the InitializeForms method and the StartProgressBar method in the background. To know when these are complete, they set class level boolean varriable to true.
C#
done=true;
VB
done=true
Qing
i'm loadingthe data from the GotFocus method, then all the controls are loaded on the page and i'm using the showdialog() method to show the next form. Maybe it will help anyone in trouble :)
cheer_jc
I do this to update a progress bar. You would create and add the controls in the following method. And call it from the background thread.
c#
//The method that needs to run on the main thread
void incrementProgressbar(int Increment)
{
progressBarSplash.Value += Increment;
}
Next create a delegate that maches the above method signature.
public delegate void ProgressBarDelegate(int Increment);
Finally call it from the background thread.
//The method running on the background thread
void StartProgressBar()
{
int count = 0;
double decay = 1;
do
{
count++;
Application.DoEvents();
Thread.Sleep(100);
if (count >= (int)decay)
{
decay *= 1.3;
//Call to the Main Thread
progressBarSplash.Invoke(new ProgressBarDelegate
(this.incrementProgressbar), new object[] { 3 });
}
} while (!done);
//Call to the Main Thread
progressBarSplash.Invoke
(new ProgressBarDelegate(this.incrementProgressbar)
, new object[] { -1 });
}
vpeh
However, when I try to do this, I get an argument exception when adding controls to a panel on the form.
Any ideas The setup function works fine if I run it inline.
Thanks