Created
December 15, 2015 06:39
-
-
Save battleguard/a42f4994fc7fc8428e5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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