Share via


How to: Program the Progress Bar Region of the Status Bar

The Progress Bar region of the Visual Studio status bar displays the incremental progress of quick operations, such as saving a single file to disk.

To use the Progress Bar region of the Visual Studio status bar

  1. Obtain an instance of the IVsStatusbar interface, which is made available through the SVsStatusbar service.

  2. Initialize the progress bar with starting values by calling the Progress method.

  3. Update the progress bar as your operation proceeds by setting new values using the Progress method.

Example

This example demonstrates how to initialize and update the progress bar.

void ProgressBarExample()
{
    IVsStatusbar statusBar = 
        (IVsStatusbar)GetService(typeof(SVsStatusbar));
    uint cookie = 0;
    string label = "Progress bar label...";

    // Initialize the progress bar.
    statusBar.Progress(ref cookie, 1, "", 0, 0);

    for (uint i = 0, total = 100; i <= total; i+)
    {
        // Display incremental progress.
        statusBar.Progress(ref cookie, 1, label, i, total);
        System.Threading.Thread.Sleep(1);
    }

    // Clear the progress bar.
    statusBar.Progress(ref cookie, 0, "", 0, 0);
}

In the above example, the code:

  • Obtains an instance of the IVsStatusbar interface from the SVsStatusbar service.

  • Initializes the progress bar to given starting values by calling the Progress method.

  • Simulates an operation by iterating through a for loop and updating the progress bar values using the Progress method.

  • Clears the progress bar using the Clear method.

See Also

Tasks

How to: Read from and Write to the Feedback Region of the Status Bar

How to: Use the Animation Region of the Status Bar

How to: Program the Designer Region of the Status Bar

Concepts

Status Bar