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

  • Thread starter Thread starter Dieter Verlaeckt
  • Start date Start date
D

Dieter Verlaeckt

Hi,

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?

TIA

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

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
:)

Dieter
 
Back
Top