BHO/ATL/COM 中的线程。 Winapi 还是其他什么?

发布于 2024-10-04 17:43:51 字数 277 浏览 1 评论 0 原文

我编写 IE 插件并使用 ATL。我需要创建后台工作线程,以便 UI 线程将尽快解除阻塞。 我的问题是,我应该使用尽可能最低的方式创建线程,即 Winapi,CreateThread 等。

或者是否有其他提供的方法在 BHO/ATL/COM 项目中创建工作线程?

我必须先学习这些东西,所以我想我会先问;)

I writing IE add-on and I'm using ATL for it. I need to create background worker thread so UI thread will be unblocked as soon as possible.
My question is, should I use the lowest possible way of creating thread which is Winapi, CreateThread etc.

Or is there other proffered way of creating worker thread in BHO/ATL/COM projects?

I have to learn this stuff first so I thought I would ask first ;)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

谢绝鈎搭 2024-10-11 17:43:51

除非您需要它们提供的控制级别,否则无需使用低级 API。

使用 ATL,您已经拥有 CWorkerThread,但您也可以使用其他库,例如 如果您愿意,可以使用 Boost.Thread

There is no need to use low-level APIs unless you need the level of control they offer.

With ATL you already have CWorkerThread, but you could also use other libraries like Boost.Thread if you prefer.

一口甜 2024-10-11 17:43:51

如果您要一直访问 API,则 如果您的线程将使用 CRT,则 _beginthreadex 优于 CreateThread()。 (如果你不知道,它可能会)

If you are going all the way down to the API, then _beginthreadex is preferred over CreateThread() if your thread will use the CRT. (If you don't know, it probably will)

萌能量女王 2024-10-11 17:43:51

通常,您会使用 boost::thread、Visual Studio ConCRT 或 Intel TBB,具体取决于您的线程需求有多极端。对于最简单的用途,选择 boost::thread。对于更高级的用途,请选择 ConCRT 或 TBB。除非您非常迫切需要其他库中未提供的某些功能,否则不要使用 WinAPI。简单的事实是,如果您用 C++ 编写一个库,那么使用 WinAPI 进行线程就像回到汇编程序来编写程序一样。继续使用 C++ - 使用 Boost。

Typically, you would use boost::thread, the Visual Studio ConCRT, or Intel TBB, depending on how extreme your threading needs are. For the simplest uses, pick boost::thread. For the more advanced uses, pick the ConCRT or TBB. Don't use WinAPI unless you're seriously desperate for some feature not offered in the other libraries. The simple fact is that if you write a library in C++, then going to use the WinAPI for threads is like going back to assembler to write your program. Stay in C++ - use Boost.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文