public void HandleEvent(FlashLightEvent evt) { switch (_currentState) { case FlashLightState.On: _currentState = FlashLightState.Off; Off(); break; case FlashLightState.Off: _currentState = FlashLightState.On; On(); break; } }
public void HandleEvent(FlashLightEvent evt) { switch (_currentState) { case FlashLightState.On: _currentState = FlashLightState.Off; Console.WriteLine("Flaslight off"); break; case FlashLightState.Off: _currentState = FlashLightState.On; Console.WriteLine("Flaslight on"); break; } }
public void SetState(FlashLightEvent evt) { switch (_currentState) { case FlashLightstate.On: _currentState = FlashLightstate.Off; Console.WriteLine("Flashlight Off"); break; case FlashLightstate.Off: _currentState = FlashLightstate.On; Console.WriteLine("Flashlight On"); break; } }
public void HandleEvent(FlashLightEvent evt) { while (true) { switch (_currentState) { case FlashLightState.On: _currentState = FlashLightState.Off; Console.WriteLine("Turned off"); Thread.Sleep(500); break; case FlashLightState.Off: _currentState = FlashLightState.On; Console.WriteLine("Turned On"); Thread.Sleep(500); break; } } }