Hello,

I'm having a Form.Show() hang up on me. I currently have one class that has a listen() method that runs in its own thread. Then I Have another class that is my actual Windows Form with all the GUI stuff. The listen() method calls methods of my Windows Form. One of those methods initializes another Windows Form inside the Windows Form and shows it, and my program hangs up when it tries to show it. I'm almost positive it's a threading issue, and I'm not sure what to do. Any suggestions? Thanks!

Member Avatar for iamthwee

I'm almost positive it's a threading issue, and I'm not sure what to do. Any suggestions?

Me too. Try changing the code to make it work.

Actually I'm not sure with kind of coding that you do (maybe a code snippet will help), but from what I'm understanding from reading your post, that you try to invoke GUI-related function from non-GUI thread. Is that true?

If so, it's happened to be like that. That a .NET code will crash if you tried to invoke GUI-related things from another thread. All the GUI-related things must be invoked using it's own GUI/form thread.

Try to invoke it using Control's Invoke or BeginInvoke.

Regards,

Lok

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.