VC++ COM-addin: threads get killed on Outlook shutdown?


Dieter Verlaeckt


I'm developing a COM-addin for Outlook in VC++ .NET using ATL/MFC.

My addin manipulates some items in Outlook when the user clicks a button on
a custom toolbar. The operation is lengthy, so i do it in a seperate worker
thread. Everything works fine and the threads can be stopped cleanly when
Outlook is running.

The problems occur when Outlook is shut down when the thread is still
running. It seems that the thread simply gets stopped (killed?suspended?) on
shutdown. I have tried to intercept Outlook shutdown in OnBeginShutdown,
OnDisconnection, and in the close event of the main explorer, but the thread
seems to have already stopped at those stages.

So my question is:

How do I prevent Outlook from shutting down until my thread has finished?



Dieter Verlaeckt

I have managed to solve the problem after A LOT of experimentation.. thx for
reading anyway :)

Walter Crosby


It would be great if you could tell us how you resolved this!


Dieter Verlaeckt


Sorry for the late reaction.. haven't read the group in a while.

In the worker thread i call CreateInstance to get an Outlook instance.
Outlook then waits nicely until my worker thread releases that instance
before it exits. The CreateInstance doesn't actually seem to create a new
instance, it seems to take the existing one. I'm a COM newbie, so I don't
know why it does that, all i know is that it works for me..

If anyone feels an unsuppressable urge to enlighten me on that.. feel free


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