Outlook Object Model and Multi-Threading

T

tms

Is it possible to safely access Outlook data via Outlook PIA's in a C#
windows application using multi-threading?

I am aware that the documentation for MAPI (http://msdn.microsoft.com/
en-us/library/cc963760.aspx)
states that the Outlook Object model is not suitable for multithreaded
code.

I have sample code that works on my local machine, however, what are
the possible consequences I may run into?
Is there a safe work around?

Thanks
 
B

Brian Tillman [MVP - Outlook]

Is it possible to safely access Outlook data via Outlook PIA's in a C#
windows application using multi-threading?

I am aware that the documentation for MAPI (http://msdn.microsoft.com/
en-us/library/cc963760.aspx)
states that the Outlook Object model is not suitable for multithreaded
code.

I have sample code that works on my local machine, however, what are
the possible consequences I may run into?
Is there a safe work around?

I'd ask this question in microsoft.public.outlook.program_vba where the coders
post.
 
K

Ken Slovak - [MVP - Outlook]

It's documented that this is not suitable, why would you think it is?

While you may not be seeing bad effects at the moment, you will crash or
hang Outlook in time doing that. You will also hang or crash other people's
code running in Outlook.

Please do not adopt a worst practice for programming Outlook, or if you do,
please never deploy your code to other Outlook installations.
 
M

Miguel Santos

I do agree with Ken.
The PIA is COM based and it runs properly only when running on the main thread. Thus, your code is not thread-safe.

The easy way to prove this is try to run multiple instances of your program.



Ken Slovak - [MVP - Outlook] wrote:

it is documented that this is not suitable, why would you think it is?
08-Oct-09

it is documented that this is not suitable, why would you think it is

While you may not be seeing bad effects at the moment, you will crash o
hang Outlook in time doing that. You will also hang or crash other people'
code running in Outlook

Please do not adopt a worst practice for programming Outlook, or if you do
please never deploy your code to other Outlook installations

-
Ken Slova
[MVP - Outlook
http://www.slovaktech.co
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

Previous Posts In This Thread:

I'd ask this question in microsoft.public.outlook.
I'd ask this question in microsoft.public.outlook.program_vba where the coder
post
-
Brian Tillman [MVP-Outlook]

it is documented that this is not suitable, why would you think it is?
it is documented that this is not suitable, why would you think it is

While you may not be seeing bad effects at the moment, you will crash o
hang Outlook in time doing that. You will also hang or crash other people'
code running in Outlook

Please do not adopt a worst practice for programming Outlook, or if you do
please never deploy your code to other Outlook installations

-
Ken Slova
[MVP - Outlook
http://www.slovaktech.co
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

Outlook Object Model and Multi-Threading
Is it possible to safely access Outlook data via Outlook PIA's in a C
windows application using multi-threading

I am aware that the documentation for MAPI (http://msdn.microsoft.com
en-us/library/cc963760.aspx
states that the Outlook Object model is not suitable for multithreade
code

I have sample code that works on my local machine, however, what ar
the possible consequences I may run into
Is there a safe work around

Thanks


Submitted via EggHeadCafe - Software Developer Portal of Choice
ASP.NET Session State FAQs
http://www.eggheadcafe.com/tutorial...b3-6663b41660b9/aspnet-session-state-faq.aspx
 

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