退出一个C#WinForms应用程序 [英] Exiting a C# winforms application

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

问题描述

我有一个应用程序从Excel中导入数据。然而,当我运行的WinForms应用程序,我intrupt的应用程序,使用 System.Windows.Forms.Application.Exit(); 我仍然可以看到MyAppName.vshost32 .EXE任务管理器中运行。

I have an application that imports data from Excel. However, when I run the winforms app and I intrupt the application, using System.Windows.Forms.Application.Exit(); I can still see the "MyAppName".vshost32.exe running in task manager.

当我退出在调试模式下的应用,窗体关闭,但VS IDE不是停止。

When I exit the application in debug mode, the form closes, but the VS IDE is not "stopped".

我如何确保应用程序正确结束。

How do I ensure the application ends correctly.

推荐答案

的过程不会终止,因为它仍然有运行 前台线程。

The process doesn't terminate because it still has foreground threads running.

如果您在创建应用程序的线程,你需要将它们标记为背景线程或者确保当您想要的应用程序退出,他们终止。

If you create threads in your application you need to mark them as background threads or make sure they terminate when you want the application to exit.

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

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