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-
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?
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-
Code:
CaptureForm cf = new CaptureForm();
showHide = true;
cf.Show();
Application.Run();
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?