Using the Outlook object model from anywhere but your main thread, without
marshaling calls to the object model back to that thread, is a great way to
crash or hang Outlook.
You really shouldn't be passing an Outlook object to the background thread.
What you should do is set up a struct or something with the properties you
need from that Outlook object and passing the struct to your background
worker thread. That way all calls to the object model are done from the main
thread.
I use delegate event handlers in my main code to receive events fired by the
worker thread when the work is finished.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
"Dorian" wrote in message
news

I've looked over a few posts on multi threading with the OOM and I
understand
that the OOM itself is restricted to being single threaded. I could use
some
information on how this works.
What I currently have is a MailItem object being passed to a new
background
thread every time an event occurs (Explorer.SelectionChange for example).
In
the thread I access things like SenderEmailAddress, ReplyRecipients. Is
this
thread safe?
What happens if I access a OOM object from the worker thread that wasn't
explicitly passed to it (Example: changing the visibility of a button on a
ribbon bar). I'm guessing this isn't thread safe.
Is there any way to trigger an event on the main thread once the worker
thread has finished running? I am used to doing this with forms, and
having a
worker thread invoke a delegate on the main form. Since we're not working
with forms, or even controls for that matter, how would I go about doing
this?