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

最后都变了- 提交于 2019-12-11 03:19:57

问题


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 ;)


回答1:


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.




回答2:


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)




回答3:


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.



来源:https://stackoverflow.com/questions/4285346/threading-in-bho-atl-com-winapi-or-something-else

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!