INFO: Disabling Thread Library Calls in Windows CE Can Improve System Performance (304280)



The information in this article applies to:

  • Microsoft Windows CE Operating System, Versions 3.0

This article was previously published under Q304280

SUMMARY

In Windows CE 3.0, dynamic link libraries (DLLs) that do not require thread notifications can help improve performance in the system by calling DisableThreadLibraryCalls(). This disables all DLL_THREAD_ATTACH and DLL_THREAD_DETACH notification calls, which will help improve overall system performance.

MORE INFORMATION

System-level DLLs, driver DLLs, and DLLs that are part of a multithreaded application may not need to receive thread notifications. If all DLLs that do not need thread notifications implement this optimization, it will greatly reduce the number of unnecessary thread notifications that are generated in the system.

To implement this optimization, a DLL should call DisableThreadLibraryCalls() from its DLL_PROCESS_ATTACH code in DllMain. For example:
BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
  switch (ul_reason_for_call)
  {
    case DLL_PROCESS_ATTACH:
      DisableThreadLibraryCalls ((HMODULE)hModule);
      break;
    case DLL_THREAD_ATTACH:
      break;
    case DLL_THREAD_DETACH:
      break;
    case DLL_PROCESS_DETACH:
      break;
  }
  return TRUE;
}
				

Modification Type:MinorLast Reviewed:12/27/2003
Keywords:kbinfo KB304280