C#强制关闭应用程序 [英] C# force close application

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

问题描述

Hello guys / girls,



我面临一个c#console应用程序的奇怪情况...

我得到的应用程序使用一些第三方组件,我没有控制权。我唯一知道的第三方组件会触发在其环境中运行的3个子进程。

一切都很好并按预期运行,但问题是这个第三方组件在关闭进程/子进程时出现问题,并且我的控制台应用程序在完成工作时没有关闭。

我试过添加

Hello guys/girls,

I am facing a really odd situation with c# console application...
The app I got uses some 3rd party component, that I don't have a control of. The only thing I know this 3rd party component fires 3 sub processes which run in their environment.
Everything is fine and run as expected, but the problem is that this 3rd party component has issues closing the processes/sub-processes and my console application does not close when it finishes performing work.
I've tried adding

Environment.Exit(0)

最后,但控制台仍在运行,在任务管理器中我可以看到3个同名的进程(控制台应用程序名称)。所以过了一会儿,当我连接到我们的工作机器时,我可以看到大量未封闭的控制台窗口,基本上什么都不做,只是坐着RAM占用。

但是 - 当我在控制台窗口中单击X时 - 它与这些虚假子流程一起正常关闭而没有任何问题...

任何人都知道怎么可能我以编程方式在控制台应用程序上调用X(关闭)事件或以某种保证方式关闭它?



谢谢!



我尝试过:



尝试调用Environment.Exit(0)

at the end, but the console remains running and in the task manager I can see 3 processes of the same name (console app name). So after a while, when I connect to our working machine I can see tons of unclosed console windows that basically do nothing and just sit with RAM occupied.
But - when I click "X" in console window - it closes fine together with these "bogus" sub-processes without any problems...
Anyone know how could I programatically invoke "X" (close) event on the console application or close it in some guaranteed way?

Thanks!

What I have tried:

Tried calling "Environment.Exit(0)"

推荐答案

你可以做这样的事情



[ ^ ]
you can do some thing like this

[^]


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

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