39059

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

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

Answer1:

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.

Answer2:

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)

Answer3:

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.

Recommend

  • Internet Explorer BHO, writing to registry and admin privileges
  • Equivalent of every-pred, but for any of the given predicates
  • Best style for iterating over a small number of items in Python?
  • ASP Net Core - Mixing External Identity Provider with Individual User Accounts for Audit Tracking
  • Dart HTTP server and Futures
  • How can we extract the main verb from a sentence?
  • SOCKS in C/C++ or another language?
  • What's a better way to swap two argument values?
  • Create ranking for vector of double
  • How to use a decaying learning rate with an estimator in tensorflow?
  • “Complex Header” not responsive in current DataTables.net build?
  • Variant from android-autofittextview library : scaling makes strange behaviour
  • Using multiple input pipelines in TensorFlow
  • Get rendered html code in Backing Component from Composite Component
  • record audio in HTML / js without Flash?
  • C++ and JS RegEx equivalent of \\p{L}
  • Connect Node.js with Oracle on Windows platform
  • How can I emulate a recursive type definition in C++?
  • in batch how do i use taskkill properly
  • Local Development, Apache vs Developer - file permissions
  • Implement JwtBearer Authentication in NSwag SwaggerUi
  • Access user's phone number on iOS 7
  • How can I tell a form not to dispose a particular control when it closes?
  • Hash Code in SQL Server?
  • Possible to “watch” both HAML and SASS at the same time?
  • How to specify input and output paths from cmd.exe for a PowerShell script?
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • Read text file that is not in the main package in a runnable jar
  • Alternative To body {overflow:scroll;} That Will Prevent Page Jostling/Wriggling?
  • Do I need to reset a Perl hash index?
  • Setting up SourceTree to merge unity3d scenes with UnityYAMLMerge
  • Unity3D & Android: Difference between “UnityMain” and “main” threads?
  • Spray.io: When (not) to use non-blocking route handling?
  • Can Jackson SerializationFeature be overridden per field or class?
  • VS2008 Enable C++ Exception with SEH
  • Redux, normalised entities and lodash merge
  • Why winpcap requires both .lib and .dll to run?
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Android Studio and gradle
  • How to get NHibernate ISession to cache entity not retrieved by primary key