At this point, the total number of PDF files found will display in the “ RichTextBox” output area, the total duration of the process will be displayed, and the progress bar will increment to completion.I wrote a PowerShell function called Copy-WithProgress that will achieve what you are after.
When the background job ends, the “ CompletedScript” script block section executes. In this section, the progress bar method PerformStep() will trigger the bar to increment. While the job is processing in the background, the PDF files in the selected folder are being displayed in the output “ RichTextBox” control, the timer is counting, and the progress bar increments while processing.Īll of this action is being handled by the “ UpdateScript” script block section in the Add-JobTracker function: $updateScript = ", # - Prepare Splatter variable to submit to background job:Īt this point, the function will submit the job for processing in the background.
The form also provides an option to interrupt the job at any time and includes a time-lapse display. This application is an example of a “responsive” form which prevents the form from freezing during job execution. In this scenario, we show the use of the progress bar while processing a background job. GUI Application for Listing PDF Documents We also demonstrate how to interrupt the running job. In Part 4 of the Progress Bar series, we integrate a progress bar control in a GUI application that submits a job for background processing.