Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > Falta 3 segundos para o terminar
- > Falta 2 segundos para o terminar
- > Falta 1 segundos para o terminar
- private static void Timer(Object o)
- {
- Console.Clear();
- GC.Collect();
- }
- Timer t = new Timer(Timer, null, 0, 3600000);
- class Program
- {
- static TimeSpan intervalo;
- static void Main(string[] args)
- {
- intervalo = TimeSpan.FromSeconds(10);
- Timer t = new Timer(ClearConsole, null, 0, 1000);
- while (true)
- {
- Console.WriteLine("Aplicação rodando...");
- Thread.Sleep(3000);
- }
- }
- private static void ClearConsole(object state)
- {
- if (intervalo.TotalSeconds == 0)
- {
- intervalo = TimeSpan.FromSeconds(10);
- Console.Clear();
- }
- else
- {
- intervalo = intervalo - TimeSpan.FromSeconds(1);
- if (intervalo.TotalSeconds <=5)
- {
- Console.WriteLine("Console será limpo em " + intervalo.TotalSeconds + " segundos...");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment