Click here to Skip to main content
15,900,378 members
Home / Discussions / C#
   

C#

 
QuestionWindows form and controls not handling focus properly Pin
likefood8-Jan-07 11:42
likefood8-Jan-07 11:42 
AnswerRe: Windows form and controls not handling focus properly Pin
likefood8-Jan-07 11:58
likefood8-Jan-07 11:58 
QuestionWindows closing itself in a thread Pin
suck1238-Jan-07 11:21
suck1238-Jan-07 11:21 
AnswerRe: Windows closing itself in a thread Pin
Judah Gabriel Himango8-Jan-07 12:41
sponsorJudah Gabriel Himango8-Jan-07 12:41 
GeneralRe: Windows closing itself in a thread Pin
suck1238-Jan-07 19:22
suck1238-Jan-07 19:22 
GeneralRe: Windows closing itself in a thread Pin
Mircea Puiu8-Jan-07 23:54
Mircea Puiu8-Jan-07 23:54 
GeneralRe: Windows closing itself in a thread Pin
suck1239-Jan-07 2:18
suck1239-Jan-07 2:18 
GeneralRe: Windows closing itself in a thread Pin
Judah Gabriel Himango9-Jan-07 5:15
sponsorJudah Gabriel Himango9-Jan-07 5:15 
Try this:

Thread wat = new Thread(GetData);

// This next line is required since you're going to be 
// creating UI controls on the thread.
wat.SetApartmentState(System.Threading.ApartmentState.STA); 

// This next line will prevent the application from exiting if the background thread is still running.
wat.IsBackground = false;

wat.Start();

...

void GetData()
{
   form.ShowDialog();
}


Let me ask you a question, though: why are you creating a new thread to create the form? You're creating lots of extra work for yourself by creating a new thread to launch the form. If you keep all the UI controls created on the same thread, things will be much easier for you.

Thus, I recommend you create all your UI controls on the same thread.


Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Check out this cutie
The apostle Paul, modernly speaking: Epistles of Paul

Judah Himango


GeneralRe: Windows closing itself in a thread Pin
suck1239-Jan-07 5:43
suck1239-Jan-07 5:43 
QuestionSounds with c# Pin
sno-18-Jan-07 9:30
sno-18-Jan-07 9:30 
AnswerRe: Sounds with c# Pin
Thomas Stockwell8-Jan-07 9:50
professionalThomas Stockwell8-Jan-07 9:50 
AnswerRe: Sounds with c# Pin
Christian Graus8-Jan-07 9:56
protectorChristian Graus8-Jan-07 9:56 
AnswerRe: Sounds with c# Pin
led mike8-Jan-07 10:05
led mike8-Jan-07 10:05 
GeneralRe: Sounds with c# Pin
sno-18-Jan-07 10:13
sno-18-Jan-07 10:13 
AnswerRe: Sounds with c# Pin
Judah Gabriel Himango8-Jan-07 10:12
sponsorJudah Gabriel Himango8-Jan-07 10:12 
AnswerRe: Sounds with c# Pin
Luc Pattyn8-Jan-07 10:18
sitebuilderLuc Pattyn8-Jan-07 10:18 
QuestionWindows list dropdown problem Pin
Matthew Cuba8-Jan-07 9:16
Matthew Cuba8-Jan-07 9:16 
AnswerRe: Windows list dropdown problem Pin
Christian Graus8-Jan-07 9:19
protectorChristian Graus8-Jan-07 9:19 
GeneralRe: Windows list dropdown problem Pin
Matthew Cuba8-Jan-07 10:22
Matthew Cuba8-Jan-07 10:22 
QuestionHow to save page as MHT with ASP/C# Pin
Todd82TA8-Jan-07 9:14
Todd82TA8-Jan-07 9:14 
AnswerRe: How to save page as MHT with ASP/C# Pin
Christian Graus8-Jan-07 9:24
protectorChristian Graus8-Jan-07 9:24 
Question"coselecting" text in a TextBox or RichTextBox Pin
Clive Pottinger8-Jan-07 8:57
Clive Pottinger8-Jan-07 8:57 
AnswerRe: "coselecting" text in a TextBox or RichTextBox Pin
Luc Pattyn8-Jan-07 9:55
sitebuilderLuc Pattyn8-Jan-07 9:55 
QuestionMDI Menustrip not merged (bug?) Pin
AndrusM8-Jan-07 8:56
AndrusM8-Jan-07 8:56 
QuestionRead config file with OpenExeConfiguration? [modified] Pin
Marcus_28-Jan-07 8:12
Marcus_28-Jan-07 8:12 

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.