@SteveSandersonMS
I found a race condition and isolated it to line 65 of ComponentsDesktop.cs. If you insert a Thread.Sleep(2000) you will see it consistently as the task on line 60 does not get through enough initialization before the code on line 76 WebWindow.NavigateToUrl(BlazorAppScheme + "://app/"); gets executed.
i.e. Task.Factory.StartNew(async () =>
{
try
{
var ipc = new IPC(WebWindow);
var configurationBuilder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true);
DesktopJSRuntime = new DesktopJSRuntime(ipc);
completed.Set();
await PerformHandshakeAsync(ipc);
The ManualResetEventSlim will prevent the WebWindow.NavigateToUrl from running until DesktopJSRuntime has been initialized. This seems to fix the problem but I'm not sure if there are other issues or not with the race between NavigateToUrl and RunAsync.
@SteveSandersonMS I found a race condition and isolated it to line 65 of ComponentsDesktop.cs. If you insert a Thread.Sleep(2000) you will see it consistently as the task on line 60 does not get through enough initialization before the code on line 76 WebWindow.NavigateToUrl(BlazorAppScheme + "://app/"); gets executed.
i.e. Task.Factory.StartNew(async () => { try { var ipc = new IPC(WebWindow);
will prevent the web window from initializing correctly.
This seems to fix the problem. But further investigation is needed . . . var completed = new ManualResetEventSlim();
.....
private static async Task RunAsync(IPC ipc, CancellationToken appLifetime, ManualResetEventSlim completed)
{
The ManualResetEventSlim will prevent the WebWindow.NavigateToUrl from running until DesktopJSRuntime has been initialized. This seems to fix the problem but I'm not sure if there are other issues or not with the race between NavigateToUrl and RunAsync.