单击MessageBox后,关闭C#控制台应用程序 [英] Close C# Console Application after MessageBox click

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

问题描述

我仍在学习C#提供的所有很酷的技巧.我有一个消息框警报,计时器到期后会弹出.我想知道在用户单击消息框上的确定"按钮之后,是否有可能让控制台应用程序自行终止.在任何情况下,控制台应用程序都会自动最小化到任务栏.

谢谢.

解决方案

尝试一下:

// Terminates this process and gives the underlying operating system the specified exit code.
Environment.Exit()

MSDN:Environment.Exit方法

I'm still learning all the cool tricks C# has to offer. I have a messagebox alert that pops up after a timer expires. I'm wondering if it is at all possible to have the console application terminate on its own after the user click the "OK" button on the messagebox. The console app is automatically minimized to the taskbar if that of any circumstance.

Thanks in advance.

解决方案

Give this a go:

// Terminates this process and gives the underlying operating system the specified exit code.
Environment.Exit()

MSDN: Environment.Exit Method

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

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