本文介绍了在退出Win32应用程序之前是否必须显式停止所有线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Win32本机VC ++应用程序,在进入WinMain()时启动一个单独的线程,然后在另一个线程运行时执行一些有用的工作,然后简单地退出WinMain()-另一个线程未明确停止. >

此博客文章说,由于其他线程仍在运行,.NET应用程序在这种情况下不会终止.同样适用于本机Win32应用程序吗?

我必须在退出之前停止所有线程吗?

解决方案

是的,否则您的应用程序可能会挂起.我建议阅读Raymond Chen关于该主题的出色博客文章:

I have a Win32 native VC++ application that upon entering WinMain() starts a separate thread, then does some useful job while that other thread is running, then simply exits WinMain() - the other thread is not explicitly stopped.

This blog post says that a .NET application will not terminate in this case since the other thread is still running. Does the same apply to native Win32 applications?

Do I have to stop all threads prior to exiting?

解决方案

Yes you have, otherwise your application may hang. I recommend reading Raymond Chen's excellent blog posts on this topic:

这篇关于在退出Win32应用程序之前是否必须显式停止所有线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 06:20
查看更多