How do I transfer control of painting the main frame to a secondary UI thread while the first (main) thread is tied up in a loop, where it cannot respond to WM_PAINT messages?

Thanks,
Chris