幸亏
Peter Duniho
在回答问题时,我发现笔刷对象是在背景线程中创建的,这就是导致问题的原因。在中创建笔刷
Dispatcher
private void SetPing(long ping, string content, string tooltip)
{
try
{
this.Dispatcher.BeginInvoke(DispatcherPriority.Send, (Action)(() =>
{
this.Ping.Content = content;
this.Ping.ToolTip = tooltip;
this.SetDock();
}));
if (this.EnableColors)
{
this.Ping.Dispatcher.BeginInvoke(DispatcherPriority.Send, (Action)(() =>
{
this.Ping.Foreground = this.GetColorByPing(ping);
}));
}
}
catch (Exception ex)
{
}
}
哪里
GetColorByPing()
返回如下内容
return (SolidColorBrush)new BrushConverter().ConvertFromString("#b71c1c");