Export (0) Print
Expand All

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

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

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

Community Additions

ADD
Show:
© 2014 Microsoft