修复统计面板数据变动时UI线程错误

This commit is contained in:
ZouJin 2023-12-29 03:29:19 +08:00
parent 99cd13b21a
commit 9c2988362a

View File

@ -34,15 +34,18 @@ namespace VPet_Simulator.Windows
private void Statistics_StatisticChanged(Interface.Statistics sender, string name, LinePutScript.SetObject value)
{
var v = StatList.FirstOrDefault(x => x.StatId == name);
if (v != null)
Dispatcher.Invoke(() =>
{
v.StatCount = value.GetDouble();
}
else
{
StatList.Add(new StatInfo(name, value.GetDouble()));
}
var v = StatList.FirstOrDefault(x => x.StatId == name);
if (v != null)
{
v.StatCount = value.GetDouble();
}
else
{
StatList.Add(new StatInfo(name, value.GetDouble()));
}
});
}
private ObservableCollection<StatInfo> StatList { get; set; } = new();