Nikita Tsukanov
1 month ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
17 additions and
2 deletions
-
src/Avalonia.Base/Threading/DispatcherFrame.cs
-
tests/Avalonia.Base.UnitTests/DispatcherTests.cs
|
|
|
@ -38,7 +38,7 @@ public class DispatcherFrame |
|
|
|
/// for their important criteria to be met. These frames
|
|
|
|
/// should have a timeout associated with them.
|
|
|
|
/// </param>
|
|
|
|
public DispatcherFrame(bool exitWhenRequested) : this(Dispatcher.UIThread, exitWhenRequested) |
|
|
|
public DispatcherFrame(bool exitWhenRequested) : this(Dispatcher.CurrentDispatcher, exitWhenRequested) |
|
|
|
{ |
|
|
|
Dispatcher.VerifyAccess(); |
|
|
|
} |
|
|
|
@ -139,4 +139,4 @@ public class DispatcherFrame |
|
|
|
if (_exitWhenRequested) |
|
|
|
_cancellationTokenSource?.Cancel(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -317,6 +317,21 @@ public partial class DispatcherTests |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task DispatcherFrame_Uses_Current_Dispatcher() |
|
|
|
{ |
|
|
|
var uiThreadDispatcher = Dispatcher.UIThread; |
|
|
|
|
|
|
|
await ThreadRunHelper.RunOnDedicatedThread(() => |
|
|
|
{ |
|
|
|
var currentDispatcher = Dispatcher.CurrentDispatcher; |
|
|
|
var frame = new DispatcherFrame(); |
|
|
|
|
|
|
|
Assert.NotSame(uiThreadDispatcher, currentDispatcher); |
|
|
|
Assert.Same(currentDispatcher, frame.Dispatcher); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void ExitAllFramesShouldExitAllFramesAndBeAbleToContinue() |
|
|
|
{ |
|
|
|
|