So this is a developing story. I’m working on a WPF app again these days and how do you exit a WPF when you’re done running? Normally a user or your code might close the main/last window and the app would exit, but what else can you do?
- Application.Current.Shutdown() is what I’ve been trying and it wouldn’t work. Why? It turns out – it needs to be invoked on the dispatcher thread… ugh. Anyways – it seems to be THE WPF way, so I’m sticking with it:
- Environment.Exit(0) should work WPF or not.
- Process.GetCurrentProcess().Kill() is a rather sudden, but sure way to kill your own process.