c# - 控制台应用程序 C# 的关闭事件

标签 c# events .net-4.0 event-handling console-application

我如何知道我的 C# 控制台应用程序何时停止?有什么事件之类的吗?

谢谢!

最佳答案

使用ProcessExit应用域事件

   class Program
    {
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);           


        }

        static void CurrentDomain_ProcessExit(object sender, EventArgs e)
        {
            Console.WriteLine("exit");
        }
    }

关于c# - 控制台应用程序 C# 的关闭事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11291352/

相关文章:

c# - 使用c#备份和恢复Azure sql数据库

c# - Azure Blob 存储授权

c# - 当安装了多个版本的 VS 时,如何将 VSIX(visual studio 扩展)从本地驱动器安装到特定版本的 VS?

jquery - 在文本区域的新行上触发 jQuery 事件(不是键盘输入)

firebase - 事件和转化的区别

ios - 将触摸事件转发到另一个被接收事件的 View 部分覆盖的 View

c# - 如何将数组转换为 BindingList

c# - .NET 4.0 MemoryCache 性能计数器在哪里?

c# - LINQ SelectMany 和 Where 扩展方法忽略空值

wpf - WPF ResourceDictionary 中 StaticResource 的范围是什么?