From TRCCompSci - AQA Computer Science
Extra declarations and namespacing
using System.Timers;//Add the Timer class to allow checking how much real time has passed
private static Timer T = new Timer(5000);//Create a new instance of the class Timer with a 5 second delay between event calls
private static bool Timeout = false;//A variable to check whether time has run out
GetChoice
private static string GetChoice()
{
Timeout = false; //This ensures that each time a player enters a choice they have the right amount of time.
// . . .
T.Start();//This starts counting real time using an event.
T.Elapsed += T_Elapsed;//This subscribes the event to a delegate, it allows a method to run after a set amount of time
// . . .
//The following if clears the choice to make it tidier
if (Timeout)
{
Choice = "";
}
// . . .
}