Equivalent in C to VB's DoEvents?
Posted on 1998-12-31
I'm a former VB programmer who's moved on to C for sometime know, but as I've been learning how to do things in C that I'd done in Visual Basic, I keep coming across the need for an equivalent to the results of VB's DoEvents function.
I'm working on a program that runs in the background and waits for a program to load. Lets say I'm waiting for Notepad. In VB, I'd make a FindWindow loop, like this:
Dim hwndNotepad As Integer
hwndNotepad = FindWindow("Notepad", vbNullString)
Loop Until (hwndNotepad <> 0)
Now without that DoEvents line, my program won't be able to accept input while the loop is going. The window won't be able to be resized, no button on it can be clicked, it can't even be closed. DoEvents fixes that. But in C, I'm writing this:
hwndNotepad = FindWindow("Notepad", NULL);
} while (hwndNotepad == NULL);
That loop will of course lock up the program until Notepad comes along and ends it. But I want to be able to do other things with the program, even quit it, while the loop is going.
Is there an API function that can simply magically take care of this? Or will this require a large complicated restructuring of things? I refuse to believe that a Visual Basic function can't be matched in C.