rendered paste bodypublic class Loader
{
public static char[] LoadChars = new char[] { '|', '/', '-', '\\' };
public bool IsLoading { get; set; }
int delay;
public Loader()
{
this.delay = 100;
}
public Loader(int delay)
{
this.delay = delay;
}
public void StopLoader()
{
IsLoading = false;
}
public void StartLoader()
{
Thread thread = new Thread(new ThreadStart(DoLoader));
IsLoading = true;
thread.Start();
}
private void DoLoader()
{
int index = -1;
int positionX = Console.CursorLeft;
int positionY = Console.CursorTop;
Console.CursorVisible = false;
while (IsLoading)
{
index++;
index %= 4;
Console.CursorLeft = positionX;
Console.CursorTop = positionY;
Console.Write(Loader.LoadChars[index]);
System.Threading.Thread.Sleep(delay);
}
}
}