Skip to content
| Marketplace
Sign in
Visual Studio>Templates>RuProgressBar with StatusStrip
RuProgressBar with StatusStrip

RuProgressBar with StatusStrip

Klaus Ruttkowski

|
6,065 installs
| (0) | Free
Use of a ProgressBar in a StatusStrip also for asynchronous functions.
Download

The template automatically creates a ProgressBar and a Cancel button with each call and also deletes these controls.

With the cancel button the function can be interrupted.

The function can work with or without await.

Use the ProgressBar with StatusStrip

Nutze die ProgressBar

`private async void ToDo_Click(object sender, EventArgs e)
{

// Bereite die ProgressBar mit allen Controls vor
// Prepare the ProgressBar with all controls

// Wichtig ist das in dem Main Fenster ein StatusStrip vorhanden ist und dieses an ProgressProcessing per Referenz     
// It is important that a StatusStrip is available in the Main window and this is transferred to ProgressProcessing by reference.

ProgressProcessing progressProcessing = new ProgressProcessing(ref statusStrip);

// und rufe deine Funktion auf
// and go to your function
await TestFuctionBool(progressProcessing);

` This is what your function might look like

So könnte deine Funktion aussehen

`private async Task TestFuctionBool(ProgressProcessing progressProcessing) { // Stelle je nach Aufgabe die Parameter ein

// Set the parameters depending on the task  

progressProcessing.ProgressBar.Minimum = 0;  

progressProcessing.ProgressBar.Maximum = 1000;  

progressProcessing.ProgressBar.Step = 10;  

progressProcessing.ProgressBar.Value = 0;  


for (var i = 0; i < progressProcessing.ProgressBar.Maximum; i = i + progressProcessing.ProgressBar.Step)
{
    // Wir brechen dann aus der Schleife aus - CancelButton
    // We then break out of the loop - CancelButton
    if (progressProcessing.CancelToken.IsCancellationRequested == true) break;

    if (!(progressProcessing.progress is null))
    {
        // Der Prozess läuft noch, wir zählen ein Step weiter
        // The process is still ongoing, we count one step further
        progressProcessing.Counter = progressProcessing.Counter + progressProcessing.ProgressBar.Step;
        progressProcessing.ReportProgress(progressProcessing.Counter);
        progressProcessing.Status.Text = progressProcessing.CountText + progressProcessing.Counter.ToString();

        // Dies sind Beispielfunktionen, sie tun nichts wichtiges arbeiteten aber asynchron
        // These are sample functions, they do not do anything important but work asynchronously
        await Task.Delay(100);
    }
}
progressProcessing.DeleteControls();
return true;

}`

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft