public static async void PersonReadyToGo(Person person) { // ready seconds await Task.Run(() => { int intReadySecs = GetSeconds(person.ReadyTimeInterval); Thread.Sleep(person.ReadyTimeInterval); Console.WriteLine($"{person.FamilyTitle} gets ready in {intReadySecs} secs."); ReadyToGo.MorningPassengerCount += 1; ReadyToGo.ArePassengersReadyToGoYet(); }); }
// Note: Asynchronously runs when you DON'T return value as a Task in signature. public static async void MomGetsReady() { // ready seconds int intReadyTimeInterval = 2000; int intReadySecs = GetSeconds(intReadyTimeInterval); await Task.Run(() => { Thread.Sleep(intReadyTimeInterval); Console.WriteLine($"Mom gets ready in {intReadySecs} secs."); ReadyToGo.MorningPassengerCount += 1; ReadyToGo.ArePassengersReadyToGoYet(); }); }