Last active
May 8, 2020 06:59
-
-
Save galenguyer/3f83789b00f5869e6cc75213a0799e74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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