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

Best Practice UI handling for long-running code



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 30th 08, 05:40 PM posted to microsoft.public.outlook.program_addins
Mark Lawrence
external usenet poster
 
Posts: 1
Default Best Practice UI handling for long-running code

I've got an addin (VSTO 2008 on Outlook2007) that, upon startup, at user
option may make a web service call to get information to populate a bunch of
postItems in a folder. The web service call could take some time. If the
number of rows returned is large, creating the associated postItems could
take some time.

In previous efforts, there have been ways to manipulate the mouse icon for
the application to indicate that things are happening. I can find examples
for doing that for forms but not for the application in general. Is there a
best practice (other than "don't do that" )

Also, while working through the returned data and creating postItems, is it
necessary to pause occasionally and allow display refresh events to process
so that the user can see what's happening? If so, is there a best practice
for doing that?
Ads
  #2  
Old September 30th 08, 06:26 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Best Practice UI handling for long-running code

The actual Web service call can be made asynchronously using a background
worker thread. Any processing using the Outlook object model should always
be done in the main thread however, otherwise you crash or hang Outlook.

If the processing can take a long time using the Outlook object model then
you can divide it into a few parts and use a timer to determine when each
piece of the processing is done, say 10 items at a time or whatever. If
that's not possible due to needing to have all the data available
simultaneously then you could put up a progress dialog or something like
that to inform the user the process was ongoing. Calling to
Application.DoEvents() will allow the Windows message pump to run and will
allow the progress dialog to update. I usually do that once per loop
iteration if I'm running a long-running process.

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


"Mark Lawrence" Mark wrote in message
...
I've got an addin (VSTO 2008 on Outlook2007) that, upon startup, at user
option may make a web service call to get information to populate a bunch
of
postItems in a folder. The web service call could take some time. If the
number of rows returned is large, creating the associated postItems could
take some time.

In previous efforts, there have been ways to manipulate the mouse icon for
the application to indicate that things are happening. I can find
examples
for doing that for forms but not for the application in general. Is there
a
best practice (other than "don't do that" )

Also, while working through the returned data and creating postItems, is
it
necessary to pause occasionally and allow display refresh events to
process
so that the user can see what's happening? If so, is there a best
practice
for doing that?


 




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
Code running the Categories button Ailish Outlook - Using Forms 2 April 1st 08 10:19 AM
Strange error numbers when running code vfr_stinger@hotmail.com Outlook and VBA 8 May 9th 07 11:15 AM
VBA Code not running until editor is open gamename Outlook and VBA 0 May 17th 06 05:42 PM
Script error while running .Net Code Muhammad Usman Outlook - Using Forms 1 May 4th 06 12:17 PM
Running query from Access Form commmand using VBA code Berny Outlook and VBA 4 January 16th 06 02:12 PM


All times are GMT +1. The time now is 05:58 PM.


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.