简体   繁体   English

VB.NET应用程序没有完全关闭

[英]VB.NET Application does not fully close

When I launch my application, and press the "X" button on my app, or my quit button which deploys: me.close It will not fully close the application. 当我启动应用程序时,按我的应用程序上的“ X”按钮,或部署的退出按钮:me.close它不会完全关闭该应用程序。 Like the instance is still running in Visual Studio or if you go to task manager processes you can still see it there. 就像实例仍在Visual Studio中运行一样,或者如果您进入任务管理器进程,您仍然可以在其中看到它。 How would I get this to fully close? 我将如何完全关闭它?

One possibility is that you have some threads apart from the main thread running, and those aren't background threads. 一种可能性是,除了正在运行的主线程外,您还有一些线程,而这些线程不是后台线程。 In general, try debugging it: attach to it from VS, and use Pause button to break it, and look at what threads are there, and what they are doing. 通常,尝试调试它:从VS附加到它,然后使用“暂停”按钮将其断开,然后查看那里有哪些线程以及它们在做什么。

If you do have thread(s) running within the app, set IsBackground property as True . 如果确实有线程在应用程序中运行,请将IsBackground属性设置为True

Thread.IsBackground Property on MSDN MSDN上的Thread.IsBackground属性

Remarks 备注

A thread is either a background thread or a foreground thread. 线程可以是后台线程,也可以是前景线程。 Background threads are identical to foreground threads, except that background threads do not prevent a process from terminating. 后台线程与前台线程相同,只是后台线程不会阻止进程终止。 Once all foreground threads belonging to a process have terminated, the common language runtime ends the process. 一旦属于某个进程的所有前台线程都已终止,公共语言运行库将终止该进程。 Any remaining background threads are stopped and do not complete. 任何剩余的后台线程都会停止并且无法完成。

The "End" keyword is what you're looking for. “ End”关键字是您要寻找的。

Put it in the FormClosed event. 将其放在FormClosed事件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM