Add a
BackgroundWorker
. Handle it's
DoWork
and
ProgressChanged
events.
In the
DoWork
handler do your thing and call
ReportProgress
passing the percentage value when you need to update.
In the
ProgressChanged
handler update the progress bar using the value passed.
I made a simple wrapper
here[
^] to make this easier that you may find of use if using WinForms.