I am creating a little testing component and am running into a problem
Basically the component is a decorator on a class that controls all access to the database, it creates a form with a two buttons on it: "Simulate Lost Connection" and "Reconnect". Press the button, and instead of letting function calls pass through the wrapper starts throwing NoConnectionException()s nice and simple, and real helpful for testing.
The problem is that this particular application when it detects a lost connection raises a modal dialog box "connection lost!" that sits there until the connection is regained. Because it is modal I cannot press my nifty button to simulate regained connectivity.
What I need to do therefore is to run my little testing form in a different thread. I'm not absolutely sure how to do that. 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 shows up except for an instant.
Any idea how I go about achieving what I want?