Browse Source

Update AvaloniaSynchronizationContext to don't wrap exceptions to AggregateException when invoking from non-UI thread

The code suggested by the user makes sense to me. Reproed issue with
 ` try
            {
                var ctx = SynchronizationContext.Current;
                await Task.Run(() => ctx.Send(state => throw new ArgumentException("hello"), null));
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (AggregateException ex)
            {
                Console.WriteLine(ex.Message);
            }` this code
pull/6464/head
Tako 5 years ago
committed by GitHub
parent
commit
d082ad91d8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/Avalonia.Base/Threading/AvaloniaSynchronizationContext.cs

2
src/Avalonia.Base/Threading/AvaloniaSynchronizationContext.cs

@ -39,7 +39,7 @@ namespace Avalonia.Threading
if (Dispatcher.UIThread.CheckAccess())
d(state);
else
Dispatcher.UIThread.InvokeAsync(() => d(state), DispatcherPriority.Send).Wait();
Dispatcher.UIThread.InvokeAsync(() => d(state), DispatcherPriority.Send).GetAwaiter().GetResult();
}

Loading…
Cancel
Save