public void SetError(bool hasError) { Action setter = () => { if (hasError) { Progress.Background = new SolidColorBrush(Colors.Red); } else { Progress.ClearValue(ProgressBar.BackgroundProperty); } }; this.EnsureThread(setter, null); }