应用程序关闭事件在C# [英] Application closing event in C#

查看:195
本文介绍了应用程序关闭事件在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用NAudio编写音乐播放器。在关闭播放器之前,我想调用一些停止播放的方法。如何做到这一点?

解决方案

WinForms



订阅 Application.ApplicationExit 事件,事件处理程序执行关闭代码。



WPF



订阅 Application.Exit 事件,并在事件处理程序中执行关闭代码。


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.

这篇关于应用程序关闭事件在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆