Change property in async method in WinUI3 project will throw COMException #994
-
Here's my property [ObservableProperty]
private bool isProgressRingVisible = true; When I change it in async method private async void NavigationParameterService_ParameterChange(object? sender, BlueprintInfoViewData e)
{
await Task.Run(() =>
{
currentDefinitions = SpaceEngineerDefinitions.Load<MyObjectBuilder_Definitions>(e.FilePath);
currentBlueprint = currentDefinitions.ShipBlueprints[0];
IsProgressRingVisible = false;
});
} It will throw an exception: System.Runtime.InteropServices.COMException. OnPropertyChanged(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangedArgs.AuthorName); |
Beta Was this translation helpful? Give feedback.
Answered by
alejandro-ordonez
Jan 1, 2025
Replies: 1 comment 1 reply
-
You can bypass this by moving that to your ViewModel, create a Task and mark it as RelayCommand: [RelayCommand]
async Task MyAsyncTask(){
-- Your code
IsProgressRingVisible = false;
}
private async void NavigationParameterService_ParameterChange(object? sender, BlueprintInfoViewData e){
ViewModel.MyAsyncTaskCommand.Execute(null) //Params if needed)
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
XFEstudio
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can bypass this by moving that to your ViewModel, create a Task and mark it as RelayCommand: