Cancel Startup

Topics: Bootstrappers & IoC, Getting Started
Oct 22, 2013 at 10: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 11:40 AM
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 24, 2013 at 11:30 PM
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.