I am creating a small testing component and run into a problem
Basically, the component is a class decorator that controls all access to the database, it creates a form with two buttons on it: "Simulate a lost connection" and "Reconnect". Click the button, and instead of passing function calls through the wrapper, you start throwing NoConnectionException () with ease and simplicity, and are also useful for testing.
The problem is that this particular application, when it detects a lost connection, calls the modal dialog box "connection lost!" which is there until the connection is restored. Since this is modal, I cannot press my button to simulate a restored connection.
What I need to do is run my small test form in another thread. I'm not quite sure how to do this. I tried
new Thread( new ThreadStart( (Action)delegate {_form.Start();} ) ).Start();
But the thread closes as soon as the method returns, so the form never appears, except instantly.
Any idea how I go to achieve what I want?
source share