Skip to content

Instantly share code, notes, and snippets.

@galenguyer
Last active May 8, 2020 06:59
Show Gist options
  • Save galenguyer/3f83789b00f5869e6cc75213a0799e74 to your computer and use it in GitHub Desktop.
Save galenguyer/3f83789b00f5869e6cc75213a0799e74 to your computer and use it in GitHub Desktop.
using System;
namespace Spinner
{ public class Spinner
{ private readonly string[] _spinner_chars = new[] {"|", "/", "-", "\\" };
private int _interval;
public Spinner()
{ this._interval = 100;
}
public Spinner(uint interval)
{ this._interval = Convert.ToInt32(interval);
}
public void Spin()
{ int _curpos = 1;
Console.Write(_spinner_chars[0]);
while (true)
{ System.Threading.Thread.Sleep(_interval);
Console.Write("\b" + _spinner_chars[_curpos]);
if (_curpos == _spinner_chars.Length-1)
{ _curpos = 0;
}
else
{ _curpos++;
} } }
public Spinner WithInterval(uint interval)
{ this._interval = Convert.ToInt32(interval);
return this;
} } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment