using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading; using System.Threading.Tasks; namespace Spiner { public class Spiner { public int X { get; set; } public int Y { get; set; } private static object _locker = new object(); private char[] frames = { '\\', '|', '/', '-' }; private int _currentFrame; public bool IsComplite { get; set; } public async void Run() { while (!IsComplite) { lock (_locker) { Console.CursorVisible = false; Console.SetCursorPosition(X, Y); Console.Write(frames[_currentFrame]); Console.CursorVisible = true; } await Task.Delay(500); _currentFrame++; if (_currentFrame >= frames.Length) _currentFrame = 0; } } } class Program { static void Main(string[] args) { var spiners = new List(); while(spiners.Count<25) { spiners.Add(new Spiner() { X = spiners.Count, Y = spiners.Count }); } var sw = new Stopwatch(); sw.Start(); foreach (var s in spiners) s.Run(); while(sw.ElapsedMilliseconds<10000) { } foreach (var s in spiners) s.IsComplite = true; ; } } }