7.7. Integrating Synchronization into MFC Programs

All of the sample code in this chapter is in simple text programs designed to demonstrate synchronization. In these examples, the blocking behavior of functions like WaitForSingleObject is acceptable. In a GUI application using the 32-bit APIs or MFC, however, blocking is a problem because it shuts down the event loop.

For example, if you want to create an MFC program that waits for a file change as demonstrated in Section 7.6, you cannot simply call WaitFor- SingleObject with an infinite timeout value, and then wait. An MFC program must return to the event loop frequently so that it can continue processing user events. One solution is to use the OnIdle member function of CWinApp and poll the ...

Get Win32 System Services: The Heart of Windows® 98 and Windows® 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.