Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Start a new thread to show form - Form never shows

Reply
 
Old 4 Weeks Ago   #1 (permalink)
Curious


 
 

Start a new thread to show form - Form never shows

When I click on the OK button on the main form, I close the main form
and then start a new thread to show another form. My code is below.
But the other form never shows up! Anything wrong with my code?

private void btOK_Click(object sender, EventArgs e)
{
try
{
this.Close();

Thread sf = new Thread(new ThreadStart(ShowForm));
sf.Start();

}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}

}

private void ShowForm()
{
TestForm tf = new TestForm();
tf.Show();
}

My System SpecsSystem Spec
Old 4 Weeks Ago   #2 (permalink)
Scott M.


 
 

Re: Start a new thread to show form - Form never shows


"Curious" <fir5tsight@newsgroup> wrote in message
news:c36899b0-ef05-4874-a981-5488e707c88e@newsgroup
Quote:

> When I click on the OK button on the main form, I close the main form
> and then start a new thread to show another form. My code is below.
> But the other form never shows up! Anything wrong with my code?
>
> private void btOK_Click(object sender, EventArgs e)
> {
> try
> {
> this.Close();
>
> Thread sf = new Thread(new ThreadStart(ShowForm));
> sf.Start();
>
> }
> catch (Exception ex)
> {
> Console.WriteLine(ex.Message);
> }
>
> }
>
> private void ShowForm()
> {
> TestForm tf = new TestForm();
> tf.Show();
> }
If you are closing the main form, why start a new thread for a second form?

-Scott


My System SpecsSystem Spec
Old 4 Weeks Ago   #3 (permalink)
Curious


 
 

Re: Start a new thread to show form - Form never shows

On Oct 29, 11:09*am, "Scott M." <s-...@newsgroup> wrote:
Quote:

> "Curious" <fir5tsi...@newsgroup> wrote in message
>
> news:c36899b0-ef05-4874-a981-5488e707c88e@newsgroup
>
>
>
>
>
Quote:

> > When I click on the OK button on the main form, I close the main form
> > and then start a new thread to show another form. My code is below.
> > But the other form never shows up! Anything wrong with my code?
>
Quote:

> > * * * private void btOK_Click(object sender, EventArgs e)
> > * * * *{
> > * * * * * *try
> > * * * * * *{
> > * * * * * * * *this.Close();
>
Quote:

> > * * * * * * * *Thread sf = new Thread(new ThreadStart(ShowForm));
> > * * * * * * * *sf.Start();
>
Quote:

> > * * * * * *}
> > * * * * * *catch (Exception ex)
> > * * * * * *{
> > * * * * * * * *Console.WriteLine(ex.Message);
> > * * * * * *}
>
Quote:

> > * * * *}
>
Quote:

> > * * * *private void ShowForm()
> > * * * *{
> > * * * * * *TestForm tf = new TestForm();
> > * * * * * *tf.Show();
> > * * * *}
>
> If you are closing the main form, why start a new thread for a second form?
>
> -Scott- Hide quoted text -
>
> - Show quoted text -
You're right. I don't need a new thread.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Show calendar form another account Live Mail
Show VBScript error message in windows Form Application VB Script
Retreive wmi data and show it in form label PowerShell
Form feed at start of print job. Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46