BackgroundTasks.LightControllerVoiceCommandService.ChangeLightStateAsync C# (CSharp) Method

ChangeLightStateAsync() private method

Handles the command to change the state of all the lights.
private ChangeLightStateAsync ( ) : System.Threading.Tasks.Task
return System.Threading.Tasks.Task
        private async Task ChangeLightStateAsync()
        {
            string phrase = _voiceCommand.Properties["state"][0];
            foreach (Light light in _lights)
            {
                await ExecutePhrase(light, phrase);
                await Task.Delay(500); // wait 500ms between pings to ensure bridge isn't overloaded.
            }
            var response = CreateCortanaResponse($"Turned your lights {phrase.ToLower()}.");
            await _voiceServiceConnection.ReportSuccessAsync(response);
        }