public static string ReadLine(TimeSpan timeOut, IConsoleAnimation animation, TimeSpan animationStepFrequency) { string value = null; bool canStep = true; using (Timer timer = new Timer((a) => { if (canStep) { animation.Step(); } })) { timer.Change(0, Convert.ToInt32(animationStepFrequency.TotalMilliseconds)); value = ConsoleApp.ReadLine(timeOut); timer.Change(Timeout.Infinite, 0); } return(value); }
public static ConsoleKeyInfo ReadKey(bool intercept, TimeSpan timeOut, ConsoleKeyInfo timeOutValue, IConsoleAnimation animation, TimeSpan animationStepFrequency) { ConsoleKeyInfo value = default(ConsoleKeyInfo); bool canStep = true; using (Timer timer = new Timer((a) => { if (canStep) { animation.Step(); } })) { timer.Change(0, Convert.ToInt32(animationStepFrequency.TotalMilliseconds)); if (!ConsoleApp.ReadKey(intercept, timeOut, out value)) { value = timeOutValue; } timer.Change(Timeout.Infinite, 0); } return(value); }
public static string ReadLine(TimeSpan timeOut, IConsoleAnimation animation, TimeSpan animationStepFrequency) { string value = null; bool canStep = true; using (Timer timer = new Timer((a) => { if (canStep) animation.Step(); })) { timer.Change(0, Convert.ToInt32(animationStepFrequency.TotalMilliseconds)); value = ConsoleApp.ReadLine(timeOut); timer.Change(Timeout.Infinite, 0); } return value; }
public static ConsoleKeyInfo ReadKey(bool intercept, TimeSpan timeOut, ConsoleKeyInfo timeOutValue, IConsoleAnimation animation, TimeSpan animationStepFrequency) { ConsoleKeyInfo value = default(ConsoleKeyInfo); bool canStep = true; using (Timer timer = new Timer((a) => { if (canStep) animation.Step(); })) { timer.Change(0, Convert.ToInt32(animationStepFrequency.TotalMilliseconds)); if (!ConsoleApp.ReadKey(intercept, timeOut, out value)) value = timeOutValue; timer.Change(Timeout.Infinite, 0); } return value; }