Skip to content

Commit 07bf66d

Browse files
committed
fix(samplesapp): Fixed a cross-threading exception on UWP
1 parent 2f6173b commit 07bf66d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/UnitTestsControl.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,16 @@ private async Task ExecuteTestsForInstance(
508508
IDisposable consoleRegistration = default;
509509
CustomConsoleOutput testConsoleOutput = default;
510510

511-
if (consoleOutput.IsChecked ?? false)
511+
bool isConsoleOutput = false;
512+
bool isRunningIgnored = false;
513+
514+
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
515+
{
516+
isConsoleOutput = consoleOutput.IsChecked ?? false;
517+
isRunningIgnored = runIgnored.IsChecked ?? false;
518+
});
519+
520+
if (isConsoleOutput)
512521
{
513522
var previousOutput = Console.Out;
514523

@@ -521,7 +530,7 @@ private async Task ExecuteTestsForInstance(
521530

522531
try
523532
{
524-
var shouldRunIgnored = runIgnored.IsChecked ?? false;
533+
var shouldRunIgnored = isRunningIgnored;
525534

526535
foreach (var testMethod in tests)
527536
{

0 commit comments

Comments
 (0)