using System; using System.Threading.Tasks; namespace PluginManager.Items { public class Spinner { /// /// True if active, false otherwise /// public bool isSpinning; /// /// The Spinner constructor /// public Spinner() { isSpinning = false; } /// /// The method that is called to start spinning the spinner /// public async void Start() { isSpinning = true; int cnt = 0; while (isSpinning) { cnt++; switch (cnt % 4) { case 0: Console.Write("/"); break; case 1: Console.Write("-"); break; case 2: Console.Write("\\"); break; case 3: Console.Write("|"); break; } Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop); await Task.Delay(250); } } /// /// The method that is called to stop the spinner from spinning /// public void Stop() { if (!isSpinning) throw new Others.Exceptions.APIException("Spinner was not spinning", GetType()); isSpinning = false; } } }