I'm getting an error (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)).
What should be the problem here, my senior dev said I need to set it to the UI Thread, here's my code:
private bool CanPrintReceipt() {
return _receipt != null && !IsBusy;
}
private async void PrintReceipt() {
IsBusy = true;
try {
await _printReceiptInteractor.PrintTerminalReceiptAsync(_receipt).ConfigureAwait(false);
Dispatcher.Dispatch(() => {
this.Close();
});
} catch (Exception e) {
_log.Error($"{nameof(PrintReceipt)}: ", e);
await this._dialogService
.ShowMessageOKAsync(e.Message, "Printer Error");
} finally {
IsBusy = false; // but when i set this to true , no error
}
}
I'm having error in my other class,
public void RaisePropertyChanged([CallerMemberName]string propertyName = null)
{
if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
return;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); //here it shows that error
}
What do you guys think the problem is? There is no RunAsync, I saw that's the other solution
Thanks,
Nico