A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Multithreading



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 18th 08, 09:04 PM posted to microsoft.public.outlook.program_addins
Stuart Parker
external usenet poster
 
Posts: 15
Default Multithreading

Hi

I have an add-in that presents the user with a VB form. The form allows the
user to supply a filter for messages to move to an archive folder. I want to
provide feedback on the progress of the move process via a progress bar. Can
I safely use a backgroundworker to farm off the move process and update the
progress bar using the backgroundworker's reportprogress method.

Basically, is moving items safe when executed from a backgroundworker ?

Cheers

Ads
  #2  
Old September 18th 08, 10:12 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Multithreading

No, you need to marshal the OOM interfaces to the main Outlook thread.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Stuart Parker" wrote in message
...
Hi

I have an add-in that presents the user with a VB form. The form allows
the user to supply a filter for messages to move to an archive folder. I
want to provide feedback on the progress of the move process via a
progress bar. Can I safely use a backgroundworker to farm off the move
process and update the progress bar using the backgroundworker's
reportprogress method.

Basically, is moving items safe when executed from a backgroundworker ?

Cheers



  #3  
Old September 18th 08, 10:50 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Multithreading

The Outlook object model should only be accessed from the main thread, never
from any other thread. If you get all the data from Outlook that you need on
the main thread and store it in non-Outlook objects then you can use those
objects in another thread. Otherwise expect crashes and hangs in Outlook.

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


"Stuart Parker" wrote in message
...
Hi

I have an add-in that presents the user with a VB form. The form allows
the user to supply a filter for messages to move to an archive folder. I
want to provide feedback on the progress of the move process via a
progress bar. Can I safely use a backgroundworker to farm off the move
process and update the progress bar using the backgroundworker's
reportprogress method.

Basically, is moving items safe when executed from a backgroundworker ?

Cheers


  #4  
Old September 18th 08, 11:01 PM posted to microsoft.public.outlook.program_addins
Stuart Parker
external usenet poster
 
Posts: 15
Default Multithreading

OK that wouldn't help me as I need to move the items to another folder AND
have a responsive UI which shows progress, which would mean my move process
would have to run on another thread to not hang the UI

I wonder how others do it.

"Ken Slovak - [MVP - Outlook]" wrote in message
...
The Outlook object model should only be accessed from the main thread,
never from any other thread. If you get all the data from Outlook that you
need on the main thread and store it in non-Outlook objects then you can
use those objects in another thread. Otherwise expect crashes and hangs in
Outlook.

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


"Stuart Parker" wrote in message
...
Hi

I have an add-in that presents the user with a VB form. The form allows
the user to supply a filter for messages to move to an archive folder. I
want to provide feedback on the progress of the move process via a
progress bar. Can I safely use a backgroundworker to farm off the move
process and update the progress bar using the backgroundworker's
reportprogress method.

Basically, is moving items safe when executed from a backgroundworker ?

Cheers


  #5  
Old September 19th 08, 05:58 PM posted to microsoft.public.outlook.program_addins
Stuart Parker
external usenet poster
 
Posts: 15
Default Multithreading

Thanks.

So are per my reply to Ken, how do I display a form to show progress
information of items being moved to another folder, and ensure that progress
is updated, if I cannot run the move process on another thread?

If I run the move process on the same thread as the form, the form will
become unresponsive

I'm using VB 2008

"Dmitry Streblechenko" wrote in message
...
No, you need to marshal the OOM interfaces to the main Outlook thread.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Stuart Parker" wrote in message
...
Hi

I have an add-in that presents the user with a VB form. The form allows
the user to supply a filter for messages to move to an archive folder. I
want to provide feedback on the progress of the move process via a
progress bar. Can I safely use a backgroundworker to farm off the move
process and update the progress bar using the backgroundworker's
reportprogress method.

Basically, is moving items safe when executed from a backgroundworker ?

Cheers



  #6  
Old September 19th 08, 06:23 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Multithreading

You can update the UI and run the message pump (DoEvents) after moving each
message.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Stuart Parker" wrote in message
...
Thanks.

So are per my reply to Ken, how do I display a form to show progress
information of items being moved to another folder, and ensure that
progress is updated, if I cannot run the move process on another thread?

If I run the move process on the same thread as the form, the form will
become unresponsive

I'm using VB 2008

"Dmitry Streblechenko" wrote in message
...
No, you need to marshal the OOM interfaces to the main Outlook thread.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Stuart Parker" wrote in message
...
Hi

I have an add-in that presents the user with a VB form. The form allows
the user to supply a filter for messages to move to an archive folder. I
want to provide feedback on the progress of the move process via a
progress bar. Can I safely use a backgroundworker to farm off the move
process and update the progress bar using the backgroundworker's
reportprogress method.

Basically, is moving items safe when executed from a backgroundworker ?

Cheers





 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multithreading with C# Dorian Add-ins for Outlook 15 September 9th 08 07:29 PM


All times are GMT +1. The time now is 08:11 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.