Skip to content

Commit 32d556a

Browse files
committed
fix: Restore threading tests
1 parent 4190eb9 commit 32d556a

File tree

4 files changed

+8
-22
lines changed

4 files changed

+8
-22
lines changed

build/ci/stage-build-linux-tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ jobs:
6666
"$(build.sourcesdirectory)/src/Uno.Wasm.Threads/bin/Release/net9.0/publish/wwwroot" \
6767
"$(build.sourcesdirectory)/src/Uno.Wasm.Threading.UITests" "http://localhost:8000/"
6868
displayName: Threading UI Tests
69-
condition: eq( variables['THREAD_TESTING'], 'true' )
7069
env:
7170
BUILD_SOURCESDIRECTORY: "$(build.sourcesdirectory)"
7271
@@ -82,7 +81,6 @@ jobs:
8281
"$(build.sourcesdirectory)/src/Uno.Wasm.Threads.Aot/bin/Release/net9.0/publish/wwwroot" \
8382
"$(build.sourcesdirectory)/src/Uno.Wasm.Threading.UITests" "http://localhost:8000/"
8483
displayName: Threading AOT UI Tests
85-
condition: eq( variables['THREAD_TESTING'], 'true' )
8684
env:
8785
BUILD_SOURCESDIRECTORY: "$(build.sourcesdirectory)"
8886

build/ci/stage-build-windows-tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ jobs:
241241
"http://localhost:8000/"
242242
243243
displayName: Threading Tests
244-
condition: eq( variables['THREAD_TESTING'], 'true' )
245244
env:
246245
BUILD_SOURCESDIRECTORY: "$(build.sourcesdirectory)"
247246
@@ -258,7 +257,6 @@ jobs:
258257
"$(build.sourcesdirectory)\src\Uno.Wasm.Threading.UITests" `
259258
"http://localhost:8000/"
260259
displayName: Threading AOT Tests
261-
condition: eq( variables['THREAD_TESTING'], 'true' )
262260
env:
263261
BUILD_SOURCESDIRECTORY: "$(build.sourcesdirectory)"
264262

src/Uno.Wasm.Threads.Shared/Program.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ public static class Program
3434
private static List<string> _messages = new List<string>();
3535
private static bool _mainThreadInvoked = false;
3636
private static Timer _timer;
37+
private static SynchronizationContext _jsContext = SynchronizationContext.Current;
3738

3839
static void Main()
3940
{
4041
var runtimeMode = Environment.GetEnvironmentVariable("UNO_BOOTSTRAP_MONO_RUNTIME_MODE");
4142
Console.WriteLine($"Runtime Version: " + RuntimeInformation.FrameworkDescription);
4243
Console.WriteLine($"Runtime Mode: " + runtimeMode);
4344
Console.WriteLine($"TID: {Thread.CurrentThread.ManagedThreadId}");
45+
Console.WriteLine($"SynchronizationContext: {_jsContext}");
4446

4547
Runtime.InvokeJS("Interop.appendResult('Startup')");
4648

@@ -92,34 +94,29 @@ void DoWork(string name)
9294

9395
if ((i % 2000) == 0)
9496
{
95-
WebAssembly.JSInterop.InternalCalls.InvokeOnMainThread();
97+
Console.WriteLine("InvokeOnMainThread1");
98+
_jsContext.Post(_ => MainThreadCallback(), null);
9699
}
97100
}
98101
}
99102

103+
#pragma warning disable CA1416 // Validate platform compatibility
100104
new Thread(_ =>
101105
{
102106
Console.WriteLine($"Starting thread [tid:{Thread.CurrentThread.ManagedThreadId}]");
103107

104-
WebAssembly.JSInterop.InternalCalls.InvokeOnMainThread();
108+
_jsContext.Post(_ => MainThreadCallback(), null);
109+
Console.WriteLine("InvokeOnMainThread2");
105110

106111
DoWork("thread1");
107112
tcs.TrySetResult(true);
108113
Console.WriteLine($"Stopping thread [tid:{Thread.CurrentThread.ManagedThreadId}]");
109114
}).Start();
115+
#pragma warning restore CA1416 // Validate platform compatibility
110116

111117
await tcs.Task;
112118

113119
_event.Set();
114120
}
115121
}
116122
}
117-
118-
namespace WebAssembly.JSInterop
119-
{
120-
public static class InternalCalls
121-
{
122-
[MethodImplAttribute(MethodImplOptions.InternalCall)]
123-
public static extern void InvokeOnMainThread();
124-
}
125-
}

src/Uno.Wasm.Threads.Shared/WasmScripts/test.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,3 @@ var Interop = {
99
parent.appendChild(txt, parent.lastChild);
1010
}
1111
};
12-
13-
var DotNet = {
14-
invokeOnMainThread: function (str) {
15-
let getApplyUpdateCapabilitiesMethod = BINDING.bind_static_method("[Uno.Wasm.Threads] Uno.Wasm.Sample.Program:MainThreadCallback");
16-
getApplyUpdateCapabilitiesMethod();
17-
}
18-
}

0 commit comments

Comments
 (0)