vb6 DoEvents locks up Outlook 2007 when new mailitem is opened...

G

Guest

I have been using vb6 to build a COM Add-in for Outlook. There are parts of
the code that run in a long loop and require a DoEvents. In the case of
Outlook 2007, all is fine until a new mailitem is opened and user starts
typing an email. Once the user starts typing and a DoEvents it triggered by
the Add-in in the background then Outlook locks up indefinitely using 100%
CPU.

I have went through and eliminated any unnecessary DoEvents but if I remove
all of them then Outlook stalls until the large loops are completed.

This does not occur in Outlook 2000, 2002 or 2003.

Any suggestions?

Thanks,
Chris Smith
 
D

Dmitry Streblechenko

You should not be using DoEvents in a COM add-in - it is essentially calling
GetMessage/TranslateMessage/DispatchMessage. These functions must be called
by Outlook, not by your code; you are probably ending up stealing some
messages that Outlook is expecting.
If you have a long loop, use a separate thread.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
G

Guest

Thanks for the message. Looking for shortest path to a resolution here before
considering additional threading code.

I would agree that using DoEvents in Outlook 2007 may steal messages but in
previous Outlook versions it did not exhibit this behavior. I read in group a
posting "Subject: Accessing Outlook while addin is running - 7/9/2007" that
Ken Slovak suggested using System.Windows.Forms.DoEvents. I don't currently
see a way to access that in vb6 because it is .Net.

Is there an alternative function for DoEvents that can be accessed by vb6 to
use in a COM Add-in for Outlook 2007?

Thanks again,
Chris Smith
 
D

Dmitry Streblechenko

No, whether you call DoEvents in VB6 or System.Windows.Forms.DoEvents in
..Net won't make a difference; they all do the same thing.
A separate thread is the way to go.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top