Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoEvents in COM event?

Status
Not open for further replies.

BeanDog

Programmer
Jul 15, 2000
60
US
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 &quot;waiting for server&quot; message box. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top