Click here to Skip to main content
15,887,988 members
Home / Discussions / C#
   

C#

 
QuestionWindows Form does not show if created in other thread Pin
gehbitte20-Jul-09 3:33
gehbitte20-Jul-09 3:33 
AnswerRe: Windows Form does not show if created in other thread Pin
stancrm20-Jul-09 3:39
stancrm20-Jul-09 3:39 
GeneralRe: Windows Form does not show if created in other thread Pin
gehbitte20-Jul-09 4:27
gehbitte20-Jul-09 4:27 
GeneralRe: Windows Form does not show if created in other thread Pin
DaveyM6920-Jul-09 4:41
professionalDaveyM6920-Jul-09 4:41 
GeneralRe: Windows Form does not show if created in other thread Pin
gehbitte20-Jul-09 4:59
gehbitte20-Jul-09 4:59 
GeneralRe: Windows Form does not show if created in other thread Pin
gehbitte20-Jul-09 5:04
gehbitte20-Jul-09 5:04 
GeneralRe: Windows Form does not show if created in other thread Pin
gehbitte20-Jul-09 5:40
gehbitte20-Jul-09 5:40 
GeneralRe: Windows Form does not show if created in other thread Pin
DaveyM6920-Jul-09 7:51
professionalDaveyM6920-Jul-09 7:51 
That's because as soon as the form is shown the thread is done and so the form closes, here you're just delaying it by 10ms. What you need is the thread to not end until the form closes.

I'm no expert in threading, I know nothing apart from the principles, so treat these ideas with great caution!

You can call ShowDialog() instead of Show() as it doesn't return until the form is closed so it will stay open and be responsive, but not act as a Dialog to the form on the main thread.
void OpenBuyWindow()
{
    Form form = new Form();
    form.ShowDialog();
}


An ugly (maybe dangerous?) alternative is to replicate what happens in the Program.cs
void OpenBuyWindow()
{
    Application.Run(new Form());
}


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus)

GeneralRe: Windows Form does not show if created in other thread Pin
gehbitte20-Jul-09 21:41
gehbitte20-Jul-09 21:41 
AnswerRe: Windows Form does not show if created in other thread Pin
Luc Pattyn20-Jul-09 3:51
sitebuilderLuc Pattyn20-Jul-09 3:51 
QuestionHorizontal ScrollBar does not work in the TextBox control... anymore. Pin
iscript20-Jul-09 3:21
iscript20-Jul-09 3:21 
AnswerRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
DaveyM6920-Jul-09 3:31
professionalDaveyM6920-Jul-09 3:31 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
iscript20-Jul-09 3:39
iscript20-Jul-09 3:39 
AnswerRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
stancrm20-Jul-09 3:31
stancrm20-Jul-09 3:31 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. [modified] Pin
iscript20-Jul-09 3:43
iscript20-Jul-09 3:43 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
Luc Pattyn20-Jul-09 3:53
sitebuilderLuc Pattyn20-Jul-09 3:53 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
iscript20-Jul-09 4:28
iscript20-Jul-09 4:28 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
Luc Pattyn20-Jul-09 4:45
sitebuilderLuc Pattyn20-Jul-09 4:45 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
iscript20-Jul-09 4:58
iscript20-Jul-09 4:58 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
Luc Pattyn20-Jul-09 5:09
sitebuilderLuc Pattyn20-Jul-09 5:09 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
iscript20-Jul-09 5:04
iscript20-Jul-09 5:04 
AnswerRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
OriginalGriff20-Jul-09 3:32
mveOriginalGriff20-Jul-09 3:32 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
iscript20-Jul-09 3:45
iscript20-Jul-09 3:45 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
PIEBALDconsult20-Jul-09 5:06
mvePIEBALDconsult20-Jul-09 5:06 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
iscript20-Jul-09 5:15
iscript20-Jul-09 5:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.