Skip to content

fdesjardins/ConsoleUpdater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConsoleUpdater

Update previous output in .NET console applications

Usage

using System;
using System.Collections.Generic;
using System.Timers;
using ConsoleUpdater;

public class Program
{
  public static Timer timer;
  public static int timesWritten = 0;
  public static List<String> frames;
  
  public static void Main()
  {
    frames = new List<String>(){@"
  \o/
   |
  / \
", @"
   o
  /|\
  / \
"};
    
    timer = new Timer(500);
    timer.Elapsed += UpdateConsole;
    timer.AutoReset = true;
    timer.Enabled = true;
    
    Console.WriteLine("Press any key to exit...");
    Console.ReadLine();
    ConsoleUpdate.Clear();
    ConsoleUpdate.Done();
  }
  
  private static void UpdateConsole(Object source, ElapsedEventArgs e)
  {
    var frame = frames[timesWritten % frames.Count];
    ConsoleUpdate.Render(frame);
    timesWritten += 1;
  }
}

Credits

This is a .NET port of https://github.com/sindresorhus/log-update

License

MIT © Forrest Desjardins

About

Update previous output in .NET console applications

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages