2f61e5dc00
- Updated HookBrowserViewModel, MainViewModel, SettingsViewModel, and SyncViewModel to inherit from BaseViewModel. - Introduced BaseViewModel with methods for running actions on the UI thread. - Enhanced SyncViewModel to handle property changes on the UI thread. - Refactored ExtractorService to return ExtractorResult instead of IReadOnlyList<HookDefinition>. - Added ExtractorResult class to encapsulate extraction results, including success status and error messages. - Implemented UIProgress class for reporting progress on the UI thread. - Updated hook_groups.json with additional classes and methods for various categories. - Improved error handling and logging in ExtractorService and SyncViewModel.
23 lines
571 B
C#
23 lines
571 B
C#
using Avalonia.Threading;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
namespace gregExtractor.GUI.ViewModels;
|
|
|
|
public abstract class BaseViewModel : ObservableObject
|
|
{
|
|
protected void RunOnUIThread(Action action)
|
|
{
|
|
if (Dispatcher.UIThread.CheckAccess())
|
|
action();
|
|
else
|
|
Dispatcher.UIThread.Post(action);
|
|
}
|
|
|
|
protected async Task RunOnUIThreadAsync(Action action)
|
|
{
|
|
if (Dispatcher.UIThread.CheckAccess())
|
|
action();
|
|
else
|
|
await Dispatcher.UIThread.InvokeAsync(action);
|
|
}
|
|
} |