Browse Source
[WASM] Ensure sync context is set before running dispatcher messages (#21462)
* ensure sync context is set before running dispatcher messages
* update dispatcher test
pull/21506/head
Emmanuel Hansen
4 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
4 additions and
2 deletions
-
src/Avalonia.Base/Threading/Dispatcher.Invoke.cs
-
tests/Avalonia.Base.UnitTests/DispatcherTests.cs
|
|
|
@ -649,7 +649,8 @@ public partial class Dispatcher |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
action(arg); |
|
|
|
using (AvaloniaSynchronizationContext.Ensure(this, (DispatcherPriority)priority)) |
|
|
|
action(arg); |
|
|
|
} |
|
|
|
catch (Exception ex) when (ExceptionFilter(ex)) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -448,6 +448,7 @@ public partial class DispatcherTests |
|
|
|
}, DispatcherPriority.Background); |
|
|
|
disp.MainLoop(CancellationToken.None); |
|
|
|
|
|
|
|
disp.Send(_ => DumpCurrentPriority(), DispatcherPriority.Send); |
|
|
|
disp.Invoke(DumpCurrentPriority, DispatcherPriority.Send, TestContext.Current.CancellationToken); |
|
|
|
disp.Invoke(() => |
|
|
|
{ |
|
|
|
@ -458,7 +459,7 @@ public partial class DispatcherTests |
|
|
|
Assert.Equal( |
|
|
|
new[] |
|
|
|
{ |
|
|
|
DispatcherPriority.Normal, DispatcherPriority.Loaded, DispatcherPriority.Input, DispatcherPriority.Background, |
|
|
|
DispatcherPriority.Normal, DispatcherPriority.Loaded, DispatcherPriority.Input, DispatcherPriority.Background, DispatcherPriority.Send, |
|
|
|
DispatcherPriority.Send, DispatcherPriority.Send, |
|
|
|
}, |
|
|
|
priorities); |
|
|
|
|