Restarting a WPF app
We recently needed a way to easily restart a running Jing process, for reasons that will become apparent in an upcoming release, to which I stumbled on this entry from one of Rob Reylea’s blogs:
http://rrelyea.spaces.live.com/Blog/cns!167AD7A5AB58D5FE!2258.entry
Essentially, you make these two calls to restart a running WPF process:
System.Windows.Forms.Application.Restart();
System.Windows.Application.Current.Shutdown();
Be careful though. After confirming with Reflector, calling Shutdown() is an asynchronous call, so it’s possible to have the new instance of your process running before the current one has terminated, so make sure your app has all your data saved/in a safe state before you make these calls.
Tags: restart, restarting
You can comment below, or link to this permanent URL from your own site.