![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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(); > } -Scott |
My System Specs![]() |
| | #3 (permalink) |
| | 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 - |
My System Specs![]() |
![]() |
| 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 | |||