I am having a bit of a problem getting my application to work
properly.

RIght here is my problem...

WHen my C# windows app loads up the start form, i create a new thread
and show the splash on the new thread and put the main thread to sleep
until the splash screen has done the business, then i kill the new
thread and start another to show the login and again put the main one
to sleep. Problem i have is that my splash screen will show ie has
focus but when my login box appears it is minimised to the taskbar??
and doesnt show up on the screeen like i want it to.

Here is my Code:

//Load the Splash Screen
private void DoSplash()
{
Splash sp = new Splash();
DialogResult Res;

Res = sp.ShowDialog();
if (Res == DialogResult.Abort)
{
KillApp = true;
}

WakeThread = true;

}

//Here is my Login Form
private void ShowLogin()
{
Login lg = new Login();
DialogResult Res;

Res = lg.ShowDialog();
if (Res != DialogResult.OK)
{
KillApp = true;
}

WakeThread = true;

}

and finally my initial form constructor



//Show Splash Screen
Thread th = new Thread(new ThreadStart(DoSplash));
th.Start();
while (WakeThread == false)
{ Thread.Sleep(1000); }

th.Abort();

if (KillApp)
{ KillApplication(); }
//end of splash screen


//Show Login Box
WakeThread = false;
Thread thLogin = new Thread(new ThreadStart(ShowLogin));
thLogin.Start();
while (WakeThread == false)
{ Thread.Sleep(1000); }

thLogin.Abort();

if (KillApp)
{ KillApplication(); }
//end of Login

//GOOD TO GO.....
InitializeComponent();


Can anyone offer a suggestion to what i am doing wrong or if someone
has a better way of doing what im trying to then please let me know :)

Thanks

Re: Creating New Threads to Show a Splash and Login Screen by Cor

Cor
Mon May 12 05:39:10 CDT 2008

Gaz,

> WHen my C# windows app loads up the start form, i create a new thread
> and show the splash on the new thread and put the main thread to sleep
> until the splash screen has done the business


What is the senze of your solution, this you can do with a simple.

\\\
Form splasy = new Form();
//Set what you want on splasy
splasy.ShowDialog();
splazy.Dispose();
///

The effect is the same.

The meaning of multithreading with a splash screen is to do initialization
operations while the splash screen is showed, not to stop it.

Cor


"Gaz" <gonkowonko@gmail.com> schreef in bericht
news:d5fa972a-842d-498e-804b-9489452bad8f@a70g2000hsh.googlegroups.com...
>I am having a bit of a problem getting my application to work
> properly.
>
> RIght here is my problem...
>
> WHen my C# windows app loads up the start form, i create a new thread
> and show the splash on the new thread and put the main thread to sleep
> until the splash screen has done the business, then i kill the new
> thread and start another to show the login and again put the main one
> to sleep. Problem i have is that my splash screen will show ie has
> focus but when my login box appears it is minimised to the taskbar??
> and doesnt show up on the screeen like i want it to.
>
> Here is my Code:
>
> //Load the Splash Screen
> private void DoSplash()
> {
> Splash sp = new Splash();
> DialogResult Res;
>
> Res = sp.ShowDialog();
> if (Res == DialogResult.Abort)
> {
> KillApp = true;
> }
>
> WakeThread = true;
>
> }
>
> //Here is my Login Form
> private void ShowLogin()
> {
> Login lg = new Login();
> DialogResult Res;
>
> Res = lg.ShowDialog();
> if (Res != DialogResult.OK)
> {
> KillApp = true;
> }
>
> WakeThread = true;
>
> }
>
> and finally my initial form constructor
>
>
>
> //Show Splash Screen
> Thread th = new Thread(new ThreadStart(DoSplash));
> th.Start();
> while (WakeThread == false)
> { Thread.Sleep(1000); }
>
> th.Abort();
>
> if (KillApp)
> { KillApplication(); }
> //end of splash screen
>
>
> //Show Login Box
> WakeThread = false;
> Thread thLogin = new Thread(new ThreadStart(ShowLogin));
> thLogin.Start();
> while (WakeThread == false)
> { Thread.Sleep(1000); }
>
> thLogin.Abort();
>
> if (KillApp)
> { KillApplication(); }
> //end of Login
>
> //GOOD TO GO.....
> InitializeComponent();
>
>
> Can anyone offer a suggestion to what i am doing wrong or if someone
> has a better way of doing what im trying to then please let me know :)
>
> Thanks


Re: Creating New Threads to Show a Splash and Login Screen by Ignacio

Ignacio
Mon May 12 13:54:25 CDT 2008


> Can anyone offer a suggestion to what i am doing wrong or if someone
> has a better way of doing what im trying to then please let me know :)

Check the archives for "Ignacio machin" "splash screen"
I have posted code for doing this exactly.

Re: Creating New Threads to Show a Splash and Login Screen by parez

parez
Tue May 13 12:18:09 CDT 2008

On May 12, 4:44 am, Gaz <gonkowo...@gmail.com> wrote:
> I am having a bit of a problem getting my application to work
> properly.
>
> RIght here is my problem...
>
> WHen my C# windows app loads up the start form, i create a new thread
> and show thesplashon the new thread and put the main thread to sleep
> until thesplashscreen has done the business, then i kill the new
> thread and start another to show the login and again put the main one
> to sleep. Problem i have is that mysplashscreen will show ie has
> focus but when my login box appears it is minimised to the taskbar??
> and doesnt show up on the screeen like i want it to.
>
> Here is my Code:
>
> //Load theSplashScreen
> private void DoSplash()
> {
> Splashsp = newSplash();
> DialogResult Res;
>
> Res = sp.ShowDialog();
> if (Res == DialogResult.Abort)
> {
> KillApp = true;
> }
>
> WakeThread = true;
>
> }
>
> //Here is my Login Form
> private void ShowLogin()
> {
> Login lg = new Login();
> DialogResult Res;
>
> Res = lg.ShowDialog();
> if (Res != DialogResult.OK)
> {
> KillApp = true;
> }
>
> WakeThread = true;
>
> }
>
> and finally my initial form constructor
>
> //ShowSplashScreen
> Thread th = new Thread(new ThreadStart(DoSplash));
> th.Start();
> while (WakeThread == false)
> { Thread.Sleep(1000); }
>
> th.Abort();
>
> if (KillApp)
> { KillApplication(); }
> //end ofsplashscreen
>
> //Show Login Box
> WakeThread = false;
> Thread thLogin = new Thread(new ThreadStart(ShowLogin));
> thLogin.Start();
> while (WakeThread == false)
> { Thread.Sleep(1000); }
>
> thLogin.Abort();
>
> if (KillApp)
> { KillApplication(); }
> //end of Login
>
> //GOOD TO GO.....
> InitializeComponent();
>
> Can anyone offer a suggestion to what i am doing wrong or if someone
> has a better way of doing what im trying to then please let me know :)
>
> Thanks

This is what i have done..


// I do the login first and then load if necessary

{
splashForm = new SplashForm();
SplashForm.CheckForIllegalCrossThreadCalls = false;

BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += new
DoWorkEventHandler(worker_DoWork);

worker.RunWorkerAsync();

////////////

//Do Work Here

////////////////

splashForm.Close();

}

void worker_DoWork(object sender, DoWorkEventArgs e)
{
splashForm.ShowDialog();
}

Re: Creating New Threads to Show a Splash and Login Screen by Joachim

Joachim
Thu May 15 15:18:40 CDT 2008

Hi,

> =A0 =A0 =A0 =A0 void worker_DoWork(object sender, DoWorkEventArgs e)
> =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 splashForm.ShowDialog();
> =A0 =A0 =A0 =A0 }- Hide quoted text -

You are actually doing the work in the first thread, and just showing
the splashForm in the worker thread.
Wouldn't it make sense to do it the other way around?

You could show the splash screen, do the work in the worker thread,
wait for the work to end and then
define a RunWorkerCompletedEventHandler to close the splash screen.

This will require a cross-thread operation I think, but you can
achieve this by
following this method:

http://msdn.microsoft.com/en-us/library/ms171728(VS.80).aspx

Joachim