Hi everybody!
Pretty much generic question :-) How do I do my own multithreading in
Outlook? Straight forward path has failed (just as I suspected :-) If
I create my own thread (using SDK's _beginthreadex call) there are
certain operations that lead to disaster :-) For instance, when I try
to get Actions (pretty much innocent, huh?) on a Mail item that I just
created (in the context of the same thread) Outlook throws "Unable to
install custom action" (or something similar to that) msg box and
hangs.
I tried (in three different attempts) to call CoInitialize,
CoInitializeEx(multithreaded) OleInitialize in the beginning of my
thread execution but neither one seemed to be able to change anything.
So, HOW DO I DO multithreading in Outlook?
TIA,
Vladimir
Dmitry Streblechenko \(MVP\) - 28 Oct 2004 18:27 GMT
Outlook Object Model is not multithread safe. Why exactly do you need a
separate thread? Is there a specific Outlook method that takes too long to
execute?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> Hi everybody!
>
[quoted text clipped - 14 lines]
>
> Vladimir
Vladimir Chtchetkine - 28 Oct 2004 21:48 GMT
Well, sort of solved. I need some comments (I mean I would appreciate
them) on the approach...
In my OnStartupComplete handler I create a (hidden) window and
whenever I need to touch outlook API from an arbitrary thread (that
I've created or my async events use) I send a message to that window
(so, I have some messaging protocol) and in my window's message
handler I actually do what I need using Outlook API. I tested on the
problem that inspired initial post and it works just fine. But I
wander if that's THE approach I should take. Any comments?
TIA,
Vladimir