private void RecorderStatusChanged(object sender, RecorderStatusChangedEventArgs args) { Dispatcher.Invoke(new Action <bool>((isRunning) => { if (isRunning) { btnRecordStop.Content = "Stop"; btnRecordStop.Background = Brushes.Red; btnRunStop.IsEnabled = false; } else { btnRecordStop.Content = "●Record"; btnRecordStop.Background = Brushes.SkyBlue; btnRunStop.IsEnabled = true; scriptBox.Text = ScriptCommand.NormalizeScript(scriptBox.Text); } }), args.IsRunning); }