If i put this code in a function it works perfectly (in VS2005), Try it: { CCriticalSection ImageInfoSyncObject; CSingleLock * pImageInfoLock; pImageInfoLock = new CSingleLock(&ImageInfoSyncObject); pImageInfoLock->Lock(); pImageInfoLock->Unlock(); }