简体   繁体   中英

Application closing event in C#

I'm writing a music player using NAudio. Before I close the player, I would like to call some methods that stop the playback. How do I do this?

WinForms

Subscribe to the Application.ApplicationExit event and in the event handler do your shutdown code.

WPF

Subscribe to the Application.Exit event and in the event handler do your shutdown code.

I think that Form.closed event would be good as well.

edit: only if you have one form

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM