Cancel Startup

Topics: Bootstrappers & IoC, Getting Started
Oct 22, 2013 at 11:01 PM
My program needs to check to see if an instance is already running during startup and exit if so. I have all the code to do the checking in a function, but I'm not sure how to effectively "cancel" the bootstrapper startup.

I am already customizing my bootstrapper, but I'm not sure whether to put it in Configure or OnStartup, and what you can call to stop it. Throwing an exception causes an appcrash which is undesirable.
if( !IamFirstInstance() )
    // what to do here?
Oct 23, 2013 at 12:40 PM
I tend to prefer the OnStartup method.
The close application logic is up to you (distinguish between a forceful exit due to duplicated startup or normal exit), in any case you can make it close gracefully using Application.Current.Shutdown method.
Oct 25, 2013 at 12:30 AM
Thanks, I wasn't sure if I needed to do something specific to Caliburn Micro. I ended up doing what you said, plus a check in Configure() to skip a lot of setup.