Welcome dialog when app starts?
-
Does anybody know how show "welcome" dialog while the the rest of the application is being loaded (C#)? Thanks a lot, Andrey
-
Does anybody know how show "welcome" dialog while the the rest of the application is being loaded (C#)? Thanks a lot, Andrey
here is what im using in my apps:
AboutBox myAboutBox = new AboutBox();
myAboutBox.Show();
myAboutBox.Refresh();
// **************** SPLASH SCREEN UP *********************// do all of your loading here
Thread.Sleep(1500); // sleep for a second and a half so it at least shows for a second.
//
// Required for Windows Form Designer support
//
InitializeComponent();myAboutBox.Hide();
myAboutBox.Dispose();
// **************** SPLASH SCREEN DOWN *******************i find that you need to call the Refresh() before doing anything cpu intensive or it might not show cause its too busy processing other stuff.. still a newb.. cut me some slack :P -dz
-
here is what im using in my apps:
AboutBox myAboutBox = new AboutBox();
myAboutBox.Show();
myAboutBox.Refresh();
// **************** SPLASH SCREEN UP *********************// do all of your loading here
Thread.Sleep(1500); // sleep for a second and a half so it at least shows for a second.
//
// Required for Windows Form Designer support
//
InitializeComponent();myAboutBox.Hide();
myAboutBox.Dispose();
// **************** SPLASH SCREEN DOWN *******************i find that you need to call the Refresh() before doing anything cpu intensive or it might not show cause its too busy processing other stuff.. still a newb.. cut me some slack :P -dz
If you do a Thread.Sleep the rest of the application will not be loaded. Why don't you try something like that
public class Form1 : System.Windows.Forms.Form { .... Form2 frm= new Form2(); public Form1() { Thread thread = new Thread(new ThreadStart(StartForm2)); thread.Start(); // Do your stuff frm.Close(); } private void StartForm2() { if (frm != null) frm.ShowDialog(); } .... }
-
If you do a Thread.Sleep the rest of the application will not be loaded. Why don't you try something like that
public class Form1 : System.Windows.Forms.Form { .... Form2 frm= new Form2(); public Form1() { Thread thread = new Thread(new ThreadStart(StartForm2)); thread.Start(); // Do your stuff frm.Close(); } private void StartForm2() { if (frm != null) frm.ShowDialog(); } .... }
if you look back at my code you'll see that the
Thread.Sleep(1500)
is just to pause for a second.. i know nothing is going to happen during that time.. right above that is where i load all of my stuff.. i just pause so that the splash screen is showed for at least a second, it serves no other purpose and can be removed. this is all in my constructor for my main form.. what is the benefit of creating a thread just to show and close the dialog when you could just show and hide the dialog around the section of code that does your loading?AboutBox myAboutBox = new AboutBox();
myAboutBox.Show();
myAboutBox.Refresh();
// **************** SPLASH SCREEN UP *********************// do all of your loading here <--- this is where i do all my loading..
// sleep for a second and a half so it at least shows for a second.
Thread.Sleep(1500); // <---this can be removed, its not necessary, i just do it//// Required for Windows Form Designer support//
InitializeComponent();myAboutBox.Hide();
myAboutBox.Dispose();
// **************** SPLASH SCREEN DOWN *******************still a newb.. cut me some slack :P -dz
-
if you look back at my code you'll see that the
Thread.Sleep(1500)
is just to pause for a second.. i know nothing is going to happen during that time.. right above that is where i load all of my stuff.. i just pause so that the splash screen is showed for at least a second, it serves no other purpose and can be removed. this is all in my constructor for my main form.. what is the benefit of creating a thread just to show and close the dialog when you could just show and hide the dialog around the section of code that does your loading?AboutBox myAboutBox = new AboutBox();
myAboutBox.Show();
myAboutBox.Refresh();
// **************** SPLASH SCREEN UP *********************// do all of your loading here <--- this is where i do all my loading..
// sleep for a second and a half so it at least shows for a second.
Thread.Sleep(1500); // <---this can be removed, its not necessary, i just do it//// Required for Windows Form Designer support//
InitializeComponent();myAboutBox.Hide();
myAboutBox.Dispose();
// **************** SPLASH SCREEN DOWN *******************still a newb.. cut me some slack :P -dz
I'm sorry if I'm offended you I didn't want to criticize your code. What I'm saying is if that guy wants to show a form during the load of the real application, in my opinion is better to show it in a different thread because it guarantees that the form will be shown and you will not get a blank screen because the application is busy doing other things. But of course you can also use tricks like Refresh() or Application.DoEvents() doesn't matter.
-
I'm sorry if I'm offended you I didn't want to criticize your code. What I'm saying is if that guy wants to show a form during the load of the real application, in my opinion is better to show it in a different thread because it guarantees that the form will be shown and you will not get a blank screen because the application is busy doing other things. But of course you can also use tricks like Refresh() or Application.DoEvents() doesn't matter.
ah.. i was wondering why i had to refresh the form to make it show.. i guess i can see how having another thread could help them both.. especially if you wanted your loading form to have some sort of animation or something.. btw, i wasnt offended, i honestly wanted to know the purpose :) still a newb.. cut me some slack :P -dz
-
ah.. i was wondering why i had to refresh the form to make it show.. i guess i can see how having another thread could help them both.. especially if you wanted your loading form to have some sort of animation or something.. btw, i wasnt offended, i honestly wanted to know the purpose :) still a newb.. cut me some slack :P -dz
-
Thanks guys for your replies. Jose, when I try to close the "start" form, the main form losts focus. Any ideas how to dial with that? ------------------------ Andrey