开发者

Threading in BHO/ATL/COM. Winapi or something else?

开发者 https://www.devze.com 2023-01-27 06:29 出处:网络
I writing IE add-on and I\'m using ATL for开发者_JAVA技巧 it. I need to create background worker thread so UI thread will be unblocked as soon as possible.

I writing IE add-on and I'm using ATL for开发者_JAVA技巧 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 ;)


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.


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)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消