2017-06-17 13 views
1

私はライトの色を毎秒変更しようとしています。次のコードを使用しています。ライトの色を毎秒変更します

private async void button5_Click(object sender, EventArgs e) 
    { 
     var command = new LightCommand(); 
     command.TurnOn().SetColor("BC8F8F"); 
     command.Brightness = 128; 
     while (true) 
     { 
      command.Alert = Alert.Once; 
      command.TransitionTime = TimeSpan.FromMilliseconds(100); 
      command.TurnOn().SetColor("0054FF"); 
      command.Alert = Alert.Once; 
      command.TurnOn().SetColor("BC8F8F"); 
      command.TransitionTime = TimeSpan.FromMilliseconds(100); 

      var result = await client.SendCommandAsync(command); 
     } 
    } 

私の目標は、交互に0054FFとBC8F8F、各秒の間の色を変えているが、私はそれをデバッグするとき、唯一のBC8F8Fの色が表示されます。

私のコードにはどのような問題がありますか?

答えて

2

あなたのコードは基本的に最初のコマンドを無効にします。あなたはたぶん2つを送信する必要があり、それぞれに独自の色が入っています。

+0

どうすれば2つ送信できますか?私は1つのボタンを使用したい! –

関連する問題