I would check the conditions before even launching the application
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
MyClass main = new MyClass();
if (main.CheckConditions()) {
MyClassApplicationContext context = new MyClassApplicationContext();
Application.Run(context);
}
}
}
It would probably be easier to use, if the condition check would be a public member of the context.
var context = new MyClassApplicationContext();
if (context.CheckConditions()) {
Application.Run(context);
}
This CheckConditions
method could of course be a wrapper that in turn calls the corresponding method of MyClass
.