我如何知道我的 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/