Multithreading

S

Stuart Parker

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
 
K

Ken Slovak - [MVP - Outlook]

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

Stuart Parker

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

Stuart Parker

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
 
D

Dmitry Streblechenko

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
-
 

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