Skip to content

Spinner

Alexandru Iuga edited this page Apr 5, 2022 · 4 revisions

Description

Displays a progress-like visual bar that moves continuously. It can be used for background jobs for which the remaining work cannot be predicted.

Features

  • Custom label - Displays a custom text label in front (left) of the spinner.
  • Optional label - The label is optional. It can be hidden.
  • Visual Template - Supports templates that control the aspect of the spinner (the displayed text for each frame).
  • Custom Speed - Can change the time interval by which the frames are updated, speeding up or slowing down the animation.

Note

The Visual templates provides, for each frame the text to be displayed. It does not provide any color.

Example

Static method (quick)

Spinner.Run(() =>
{
    // Do some work here.
});

or

BubbleTemplate bubbleTemplate = new BubbleTemplate();

Spinner.Run(bubbleTemplate, () =>
{
    // Do some work here.
});

Instance (more power)

StickTemplate spinnerTemplate = new StickTemplate(),

using (Spinner spinner = new Spinner(spinnerTemplate))
{
    spinner.StepMiliseconds = SpinnerStepMilliseconds;
    spinner.Text = "Doing some work";

    spinner.Display();

    // Do some work here.

    spinner.Close();
}
Clone this wiki locally