open the form from inner thread


Apr 15, 2002
I created some kind of surfing control application. The application open a form, get from the user cardinals, and then it close up and run background thread that sends information about the surfing activity to logger.
Sometimes there is a need, of course, to open again the form to change settings… but since the back ground thread is a different thread, there is no way to open the "same" form again, nor close the net listener, each try to do so and with exception that generally says that you can't control the main process from another thread. I can't create new instance of the main form, since the network card is "busy" with the first process. I found that code that open the main form again-
                            CaptureForm cf = new CaptureForm();
                            showHide = true;

It does open the same main form, but the background thread are still collision. And any try to make changes to the running threads (like stop the capture of network movements) end with the same exceptions… I have to open the form from the background thread, since it's the only communication I have with the application after the form close. How can I catch the mainform? Or change anything in the background running threads?


Sep 4, 2002
Lancashire, UK
Rather than close the form couldn't you keep it open but hidden? That way you would be able to maintain a reference to it at all times and use the .Invoke() method to handle cross thread calls.
Top Bottom