Created
August 1, 2012 15:09
-
-
Save jakejscott/3227654 to your computer and use it in GitHub Desktop.
Console spinner
This file contains hidden or 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
public class ConsoleSpiner | |
{ | |
int counter; | |
public ConsoleSpiner() | |
{ | |
counter = 0; | |
} | |
public void Turn() | |
{ | |
counter++; | |
switch (counter % 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); | |
} | |
} |
This file contains hidden or 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
static void Main(string[] args) | |
{ | |
ConsoleSpiner spin = new ConsoleSpiner(); | |
Console.Write("Working...."); | |
while (true) | |
{ | |
spin.Turn(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment