Skip to content

Instantly share code, notes, and snippets.

@battleguard
Created December 15, 2015 06:39
Show Gist options
  • Select an option

  • Save battleguard/a42f4994fc7fc8428e5a to your computer and use it in GitHub Desktop.

Select an option

Save battleguard/a42f4994fc7fc8428e5a to your computer and use it in GitHub Desktop.
using System;
namespace ConsoleApplication2
{
class Program
{
private static DateTime _lastInvoke = DateTime.MinValue;
public static void Main()
{
ConsoleKey input;
while ( (input = Console.ReadKey().Key) != ConsoleKey.Escape )
Update( input );
}
private static void Update( ConsoleKey key )
{
if( key == ConsoleKey.Spacebar && DateTime.Now - _lastInvoke > TimeSpan.FromSeconds( 7 ) )
{
MethodA();
_lastInvoke = DateTime.Now;
}
}
public static void MethodA()
{
Console.WriteLine( "Invoked Method A" );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment