Windows Develop Bookmark and Share   
 index > Windows Forms General > New form stuck in loop?
 

New form stuck in loop?

My main form (Form1) allows the user to connect to a server. When the program receives a particular message from the server, it opens a new form (Form2). The problem is, Form2 seems to be stuck in some kind of loop: it is not being painted, and will not respond to input. The mouse cursor changes to the hourglass when moving over the form. At first I thought it was a problem with my painting code, so I used a generic Windows.Forms.Form object, and got the same problem. The really weird thing is, if I create the form in some other function (the Load event handler of Form1, for example), it works fine. Its only when I create and show the form from the function that is processing network messages that I have the problem. Does anyone have any idea what could be going on here?

Autofed
MigrationUser 1  Thursday, April 01, 2004 1:05 AM
I think I know what the problem is, I just don't know what to do about it. Because the form is being shown in the network processing function, the thread that is showing it is the thread that is performing the asynchronous read from the network stream. As soon as that thread leaves the network processing function, it exits. So I'm guessing when the thread exits, it is also shutting down the message loop for the form (or something like that). Can anyone recommend a way to get around this?

Autofed
MigrationUser 1  Thursday, April 01, 2004 2:53 PM
You should insert a few <strong>breakpoints</strong> at the relevant places in your code to allow you to step through and see where the looping happens.
MigrationUser 1  Thursday, April 01, 2004 10:39 PM

You can use google to search for other answers

Custom Search

More Threads

• How to write code in C# , whether imported excel file is saved or not
• Microsoft Visual Studio Tools for the Microsoft Office System
• Tooltip in a Listview is blinking
• Dragging & Dropping images via PictureBoxes
• windows form parameter
• invoke from another class
• Forms and UserControls
• [WINDOWS FORM/C#] Listbox looping problem + Urgent help please
• Variable size table of strings.
• Multiple recipient to send email