Hello!
Background: I have created this UserControl. In the constructor of the user control I call a function that retrieves some values from the database. If an error occurs while retrieving the values a messagebox explaining the error is shown. So far so good.
The Problem: I have created a form that (among other elements) includes my UserControl. Now when I open this form (or even the UserControl itself) the constructor is called (I suppose so it can be drawn accurately) and, because the database is unavailable, the messagebox (explained above) is shown.
How do I prevent this from happening?
I just want to be clear: the code works great in runtime. Everything is as designed. It is only in Designer view of Visual Studio (2008 SP1 if it matters) where the problem occurs. However in Designer it is awful, especially now when the application attempts to reconnect when the connection fails. Every time I go in to Designer mode my Visual Studio freezes for about 20 seconds (timeout of the reconnect) and it is killing my work process.