Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

CComAutoThreadModule Class

As of ATL 7.0, CComAutoThreadModule is obsolete: see ATL Module Classes for more details.

   class ThreadAllocator = CComSimpleThreadAllocator  
class CComAutoThreadModule : 
   public CComModule


[in] The class managing thread selection. The default value is CComSimpleThreadAllocator.


This class is obsolete, having been replaced by the CAtlAutoThreadModule and CAtlModule derived classes. The information that follows is for use with older releases of ATL.

CComAutoThreadModule derives from CComModule to implement a thread-pooled, apartment-model COM server for EXEs and Windows services. CComAutoThreadModule uses CComApartment to manage an apartment for each thread in the module.

Derive your module from CComAutoThreadModule when you want to create objects in multiple apartments. You must also include the DECLARE_CLASSFACTORY_AUTO_THREAD macro in your object's class definition to specify CComClassFactoryAutoThread as the class factory.

By default, the ATL COM AppWizard (the ATL Project Wizard in Visual Studio .NET) will derive your module from CComModule. To use CComAutoThreadModule, modify the class definition. For example:

class CMyModule : 
public CComAutoThreadModule<CComSimpleThreadAllocator>
   LONG Unlock()
      LONG l = CComAutoThreadModule<CComSimpleThreadAllocator>::Unlock();
      if (l == 0)
         PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
      return l;

   DWORD dwThreadID;

Header: atlbase.h

Community Additions

© 2015 Microsoft