From d5b1caafa90b90312a85ecd55e8ced07d7fb29df Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 14 May 2020 16:25:03 +0200 Subject: [PATCH] [TouchRunner] TestFinished may be called on a background thread, so make sure to execute any UI logic on the main thread. (#60) --- NUnitLite/TouchRunner/TouchRunner.cs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/NUnitLite/TouchRunner/TouchRunner.cs b/NUnitLite/TouchRunner/TouchRunner.cs index 8ca15a2..e20e3a7 100644 --- a/NUnitLite/TouchRunner/TouchRunner.cs +++ b/NUnitLite/TouchRunner/TouchRunner.cs @@ -653,17 +653,19 @@ public override void TestFinished (ITestResult r) { base.TestFinished (r); - TestResult result = r as TestResult; - TestSuite ts = result.Test as TestSuite; - if (ts != null) { - TestSuiteElement tse; - if (suite_elements.TryGetValue (ts, out tse)) - tse.Update (result); - } else { - TestMethod tc = result.Test as TestMethod; - if (tc != null) - case_elements [tc].Update (result); - } + ExecuteOnMainThread (() => { + TestResult result = r as TestResult; + TestSuite ts = result.Test as TestSuite; + if (ts != null) { + TestSuiteElement tse; + if (suite_elements.TryGetValue (ts, out tse)) + tse.Update (result); + } else { + TestMethod tc = result.Test as TestMethod; + if (tc != null) + case_elements [tc].Update (result); + } + }); } protected override void WriteDeviceInformation (TextWriter writer)