2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-04-05 17:39:39 -04:00

Fix a "Call from invalid thread" exception. (#72)

Random occurrence triggered by a plugin's grid update. It's either fairly rare (related to something I was doing in-app) or new with a recent update to the plugin that caused it (just updated it last night).
This commit is contained in:
F K 2022-03-25 07:17:28 -04:00 committed by GitHub
parent a6408814f7
commit 3cc8cc3abe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,7 +111,6 @@ namespace Observatory.UI.Views
{
var dataContext = ((ViewModels.BasicUIViewModel)dataGrid.DataContext).BasicUIGrid;
dataContext.CollectionChanged += ScrollToLast;
}
}
@ -121,7 +120,10 @@ namespace Observatory.UI.Views
if (e.Action != System.Collections.Specialized.NotifyCollectionChangedAction.Add || UIType != PluginUI.UIType.Basic || dataGrid == null || !(sender is ObservableCollection<object>))
return;
var dataContext = (ObservableCollection<object>)sender;
dataGrid.ScrollIntoView(dataContext[dataContext.Count - 1], null);
Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() =>
{
dataGrid.ScrollIntoView(dataContext[dataContext.Count - 1], null);
});
}
private Grid GenerateCoreUI()