I have written an out-of-process (.exe) apartment-threaded COM object in VC++6, and I make a call to it from my VB app that can take a minute to complete. So, I have the COM object call an event. VB *does* get the event and handles it fine. I have it set up to send back to the COM server whether or not to continue processing. This also works.
To allow the user to cancel the process, I put a Cancel button on a progress form and wrote this in the event code:
Private Sub g_DB_OnSearchResult(..., lContinue As Long)
If bStop Then lContinue = 0
DoEvents
End Sub
When they hit the cancel button, it sets bStop to true. Now, this all works. Sometimes. If the process doesn't take very long (<5 seconds) I can click the cancel button any time and it succeeds.
But sometimes when it takes much longer, and the OnSearchResult is called thousands of times, the DoEvents doesn't seem to take effect. When I click the Cancel button it doesn't press, I just get the standard VB "waiting for server" message box. Any ideas?
To allow the user to cancel the process, I put a Cancel button on a progress form and wrote this in the event code:
Private Sub g_DB_OnSearchResult(..., lContinue As Long)
If bStop Then lContinue = 0
DoEvents
End Sub
When they hit the cancel button, it sets bStop to true. Now, this all works. Sometimes. If the process doesn't take very long (<5 seconds) I can click the cancel button any time and it succeeds.
But sometimes when it takes much longer, and the OnSearchResult is called thousands of times, the DoEvents doesn't seem to take effect. When I click the Cancel button it doesn't press, I just get the standard VB "waiting for server" message box. Any ideas?