Monthly Archives: May 2002

Threads in MFC Part III: Exceptions, Suspense, Murder, and Safety

Exceptions In the previous tutorial, I described the various synchronization objects you can use to control access to shared objects. In most cases, these will work fine, but consider the following situation: [code lang="cpp"] UINT ThreadFunc(LPVOID lParam) { ::criticalSection.Lock(); ::globalData.DoSomething(); SomeFunctionThatThrowsException(); ::criticalSection.Unlock(); return 0; }[/code] What’s going to happen when that exception gets thrown? The [...]