Tag: C++

Obtaining number of thread context switches programmatically

Previous post on thread synchronization and context switches used number of thread context switches as one of the performance indicators. One might have hard times getting the number from operating system though. The only well documented access to amount of context switches seems to be accessing corresponding performance counters. Thread performance counter will list available…

Read the full article

Thread synchronization and context switches

A basic task in thread synchronization is putting something on one thread and getting it out on another thread for further processing. Two or more threads of execution are accessing certain data, and in order to keep data consistent and solid the access is split into atomic operations which are only allowed for one thread…

Read the full article

How to get HMODULE of msvcr90.dll

Because Microsoft C++ Runtime library is distributed as a side-by-side assembly, GetModuleHandle and LoadLibrary is no longer available to locate the library within the process. Both API calls would return NULL handle. HMODULE hModule = GetModuleHandle(_T(“msvcr90.dll”)); HMODULE hModule = LoadLibrary(_T(“msvcr90.dll”)); Still, how to locate the modules in order to, for example, be able to check…

Read the full article

Attributed ATL: Accessing BLOB with ISequentialStream

Before attributed ATL was deprecated, it was a convenient way to access databases using attributed classes on top of OLEDB Consumer Templates. Does not it look nice? [ db_command(“SELECT ServerData FROM Server WHERE Server = ?”) ] class CGetServerData { public: [ db_param(1) ] LONG m_nServer; [ db_column(1, length = “m_nDataLength”) ] ISequentialStream* m_pDataStream; DBLENGTH…

Read the full article