C
Craig Buchanan
I need to display a progress meter, that accepts cancellation, during a
long-running process in my add-in.
Originally, I planned to use the BackgroundWorker, but soon learned of the
cross-threading issues that occur w/ Outlook.
I've written a replacement, but I want to make sure that the pattern is a
decent one.
I created a progress form that contains the progress bar and a cancel
button. the form has a public method that is use to update the progress
bar's UI. it also has a Cancelled event that is triggered when the cancel
button is clicked.
In the long-running process, i create an instance of this form and delegate
it's Cancelled event to another procedure. Each time a message is sent, i
update the progress bar thru the popup's public method. doevents is called
at the end of each loop. when the process is completed, i close the popup.
in the deletegated Cancelled method, a module-level variable
"CancellationPending" is set to true. This variable is checked in the loop
mentioned above. if it is true, appropriate action is taken.
Does this seem to be a reasonable approach?
Thanks for your time,
Craig Buchanan
long-running process in my add-in.
Originally, I planned to use the BackgroundWorker, but soon learned of the
cross-threading issues that occur w/ Outlook.
I've written a replacement, but I want to make sure that the pattern is a
decent one.
I created a progress form that contains the progress bar and a cancel
button. the form has a public method that is use to update the progress
bar's UI. it also has a Cancelled event that is triggered when the cancel
button is clicked.
In the long-running process, i create an instance of this form and delegate
it's Cancelled event to another procedure. Each time a message is sent, i
update the progress bar thru the popup's public method. doevents is called
at the end of each loop. when the process is completed, i close the popup.
in the deletegated Cancelled method, a module-level variable
"CancellationPending" is set to true. This variable is checked in the loop
mentioned above. if it is true, appropriate action is taken.
Does this seem to be a reasonable approach?
Thanks for your time,
Craig Buchanan