tags:

views:

34

answers:

2

hi, are there any ways to cancel

Application.Current.Shutdown();  

background: i played with mef a little bit and put some plugins to my main app. if any plugin call

Application.Current.Shutdown();

my main app shutdown too and i got no chance to cancel this. are there any ways?

A: 

It don't look like it. So instead of having your plugins do a shutdown, instead have them call some method in your application class that will handle the shutdown request for them. See below link also for more info.

http://www.skylark-software.com/2009/10/canceling-application-shutdown-in-wpf.html

Wallstreet Programmer
A: 

The SessionEnding event handler parameter SessionEndingCancelEventArgs has an option to cancel the shutdown. Did you try that?

Veer
SessionEnding event did not fire on Shutdown() method. seems to be there is really no way to cancel shutdown().
blindmeis
Veer, did you even read the first line in your link? It says:Occurs when the user ends the Windows session by logging off or shutting down the operating system.
Wallstreet Programmer
@Wallstreet Programmer: I doubted on reading the first line. But don't know why i was convinced by the Remarks section. Anyways the answer is misleading. I'll delete it.
Veer