tags:

views:

62

answers:

2

I perform some checks in my Window class constructor, and if they fail I want to display an error message and close the window.

I'm getting crashes when calling Close() from the constructor or from Window_Loaded. Does that sounds normal or am I doing something wrong? If this is normal, when should I call Close()?

A: 

I would recommend performing those checks before showing the window and if they fail, then display the error. In other words, don't show the window unless it's ok to do so.

Chris Dunaway
+1  A: 

It turns out you can call Close() in the constructor or on Window_Loaded - I was just doing something wrong later on in the destructor.

Martin