public async void ToggleState() { if (TrafficTrafficState == TrafficState.STOP) { TrafficTrafficState = TrafficLight.TrafficState.READY; await Task.Delay(4000); TrafficTrafficState = TrafficLight.TrafficState.GO; RedLight.ToggleState(); GreenLight.ToggleState(); return; } TrafficTrafficState = TrafficState.READY; GreenLight.ToggleState(); YellowLight.ToggleState(); await Task.Delay(3000); TrafficTrafficState = TrafficState.STOP; YellowLight.ToggleState(); RedLight.ToggleState(); }
public new async Task ToggleState() { if (TrafficTrafficState == TrafficLight.TrafficState.STOP) { TrafficTrafficState = TrafficLight.TrafficState.READY; await Task.Delay(4000); TrafficTrafficState = TrafficLight.TrafficState.GO; RedLight.ToggleState(); GreenLight.ToggleState(); return; } TrafficTrafficState = TrafficLight.TrafficState.READY; GreenLight.ToggleState(); await Blink(3000, 300, RedLight); TrafficTrafficState = TrafficState.STOP; if (!RedLight.IsActive) { RedLight.ToggleState(); } }