G
Guest
I have an application where I would like to block waiting on an asynchronous
event and still process messages. I can implement a hard loop to block such
as:
Do While StillWaiting
Application.DoEvents
Loop
In this case the asynchronous thread can just set StillWaiting=False when
complete.
But this hard loop is CPU intensive. Using VB6 I solved this problem by
making my own windows message loop using WIN32 calls such as:
Do While (GetMessage(Message, 0, 0, 0) <> 0)
TranslateMessage(Message)
DispatchMessageA(Message)
If Not StillWaiting Then
Exit Do
End If
Loop
In this case the async thread needs to set StillWaiting=False and send a
message to the application message queue to wake it up.
My question is will this approach work under .NET? I've tried it and it
seems to but I am concerned about how the WIN32 calls work and/or other
issues I may be missing out on...
event and still process messages. I can implement a hard loop to block such
as:
Do While StillWaiting
Application.DoEvents
Loop
In this case the asynchronous thread can just set StillWaiting=False when
complete.
But this hard loop is CPU intensive. Using VB6 I solved this problem by
making my own windows message loop using WIN32 calls such as:
Do While (GetMessage(Message, 0, 0, 0) <> 0)
TranslateMessage(Message)
DispatchMessageA(Message)
If Not StillWaiting Then
Exit Do
End If
Loop
In this case the async thread needs to set StillWaiting=False and send a
message to the application message queue to wake it up.
My question is will this approach work under .NET? I've tried it and it
seems to but I am concerned about how the WIN32 calls work and/or other
issues I may be missing out on...