ShowDialog and Hide form, when from is called from other object in VS2010

Posted by Piotr Dabrowski on Stack Overflow See other posts from Stack Overflow or by Piotr Dabrowski
Published on 2010-12-30T14:49:51Z Indexed on 2010/12/30 14:54 UTC
Read the original article Hit count: 148

Filed under:

Hallo,
I have a modal Form, used for searching information in DB. This Form is used by a COM object, that waits for search result. Initialization of the form take a lot of time (because of building connection to DB). So, I initialize the Form (without showing it), and keep Form-object alive, as long as COM-object work. In this way I keep the state of the Form:

public void Search()
this.ShowDialog();
string result = this.ResultOfSearch;
this.Hide()
return result;

And it doesn't work anymore on VS2010 (compiled for Framework 2.0). I search for alternative way to make a modal form (or a method to protect a form against Destroy() at the end of ShowDialog).
Any ideas?

© Stack Overflow or respective owner

Related posts about c#