The await on Dispatcher.BeginInvoke does not seem to report exceptions:
private async void Button_Click(object sender, RoutedEventArgs e) { try { await Dispatcher.BeginInvoke((Action)Throw); } catch { MessageBox.Show("Catched."); } } private void Throw() { throw new Exception(); }
Interestingly enough, Dispatcher.InvokeAsync does allow the exception to be catched, although both seem to just call the internal InvokeAsyncImpl method and both return DispatcherOperation. So what's the difference, why awaiting BeginInvoke results in unhandled dispatcher exception but awaiting InvokeAsync works as expected?
What I have to do to get the exception to call site when using BeginInvoke?
Thanks,
Jan