Cinchoo – ChoConsoleSpinProgressor

Using Cinchoo framework, you can perform lengthy operation with the spin progress indicator in the console window. The feature is very useful when you want to give a visual indicator of how a task is performing.

1. Add reference to Cinchoo.Core.dll assembly

2. Namespace Cinchoo.Core.Shell.Console

Below is the sample code

int x = 0;
using (ChoConsoleSpinProgressor cp = new ChoConsoleSpinProgressor("Calculating...", ConsoleColor.Red))
    cp.ErrorOccured += (sender, eventArg) => cp.Write(eventArg.Exception.Message);
    cp.Start((sender, state) =>
            cp.ConsoleSession.WriteLine("Processing Step" + x++);

            if (x > 5)
                return false; //To indicate the completion of the operation
                return true; //To indicate continuation of the operation

When you run the above code, you can see the below output

For any exception occurred during the operation, can be captured by subscribing to ErrorOccured event.

cp.ErrorOccured += (sender, eventArg) => ((ChoConsoleSpinProgressor)sender).Write(eventArg.Exception.Message);

The custom operation can be terminated in couple of ways

1. Stop() – Graceful termination

2. Abort() – Abnormal termination

Happy coding!!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s