The
ProgressBar control[
^] has built-in support for showing indeterminate progress - just set
the Style property[
^] to
ProgressBarStyle.Marquee
:
oi1ProgressStatus.Style = ProgressBarStyle.Marquee;
await Task.Run(() =>
{
BaseParameters.ErrorBag.Clear();
if (ESignatureService.SignDocuments(documentIds, GlobalVariables.oLoginRO.PersonalSchluessel))
SaveAndPopulateDocuments();
breakFlag = false;
});
oi1ProgressStatus.Style = ProgressBarStyle.Blocks;
NB: You can't update UI elements from a background thread, so you'll need to use
Invoke
to push the updates back onto the UI thread. If you use
Task.WaitAny
on the UI thread, you'll block the
Invoke
method, and cause a deadlock. Use
async
/
await
instead, which will keep the UI thread responsive whilst your background task is running.
If you can't use
async
/
await
, then use
a BackgroundWorker[
^] to perform your task.