How to find out that the application is closing

There is a WPF application.

I want to register when the application is closed.

but I can’t change the application (some kind of limitation, simply because the business).

So, I create an invisible form component that lives inside an existing application, adding it as a dll library, so the existing application does not need to be changed.

but the problem is how does my invisible component know that the application is closing?

is there any function or event handler that i can use?

Decision:

there is some kind of event

unloaded closing closed

all three of these events will be fired when the main windows are closed.

Problem resolved

+3
3

System.Windows.Window OnClosing(CancelEventArgs) , , Closing, .

Page, , , .

, , . , , , , - , , . , , TM , , , , .

+4

FormClosing?

0

I don’t have knowledge about WPF yet, but I know from winforms, there is an event Closingfrom the class Formthat you can catch and present the dialog "This application exits, you want to continue, etc." and set the flag Cancelto true to interrupt the closing of the form, there is also an event ApplicationExitfrom the class Application, you can catch it if you want to process the closing of the application.

Hope this helps, Regards, Tom.

0
source

Source: https://habr.com/ru/post/1729476/


All Articles