November 13th, 2003

Answer to previous exercise about m_fRecursing

Answer to previous exercise: The m_fRecursing flag does not need to be per-instance. It only needs to be valid long enough that the recursive call that comes immediately afterwards can be detected. However, a global variable would not work because two threads might be inside the recursive DefDlgProc call simultaneously. But a thread-local variable would work. (If you prefer to code in plain C or don’t want to use classes, you may find this alternative easier to work with.)

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.