Guest User

Untitled

a guest
Mar 13th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. > Falta 3 segundos para o terminar
  2. > Falta 2 segundos para o terminar
  3. > Falta 1 segundos para o terminar
  4.  
  5. private static void Timer(Object o)
  6. {
  7. Console.Clear();
  8. GC.Collect();
  9. }
  10.  
  11. Timer t = new Timer(Timer, null, 0, 3600000);
  12.  
  13. class Program
  14. {
  15. static TimeSpan intervalo;
  16. static void Main(string[] args)
  17. {
  18. intervalo = TimeSpan.FromSeconds(10);
  19.  
  20. Timer t = new Timer(ClearConsole, null, 0, 1000);
  21.  
  22. while (true)
  23. {
  24. Console.WriteLine("Aplicação rodando...");
  25. Thread.Sleep(3000);
  26. }
  27.  
  28.  
  29. }
  30.  
  31. private static void ClearConsole(object state)
  32. {
  33. if (intervalo.TotalSeconds == 0)
  34. {
  35. intervalo = TimeSpan.FromSeconds(10);
  36.  
  37. Console.Clear();
  38. }
  39. else
  40. {
  41. intervalo = intervalo - TimeSpan.FromSeconds(1);
  42. if (intervalo.TotalSeconds <=5)
  43. {
  44. Console.WriteLine("Console será limpo em " + intervalo.TotalSeconds + " segundos...");
  45. }
  46. }
  47. }
  48.  
  49. }
Add Comment
Please, Sign In to add comment