Skip to content

[browser][coreclr] implement async main and ST thread pool #120212

@pavelsavara

Description

@pavelsavara

It would unlock following features that depend on yielding to browser event loop

  • Threadpool
  • GC Finalizer
  • Timers
  • HTTP & WS clients

implementation notes

  • make BrowserHost_ExecuteAssembly to yield
  • ICLRRuntimeHost4->ExecuteAssembly(domainId, managedAssemblyPathW, argc, argvW, (DWORD *)exitCode)
  • src\coreclr\vm\corhost.cpp - CorHost2::ExecuteAssembly
  • src\coreclr\vm\assembly.cpp - Assembly::ExecuteMainMethod
  • RunMain -> ValidateMainMethod, RunMainInternal
  • SystemJS_ScheduleBackgroundJob
        public static void MainWrapper(string[] args, Func<string[], Task<int>> original, Action<int> resolve, Action<string> reject)
        {
            var task = original(args);

            task.ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    reject(t.Exception.Message);
                }
                else
                {
                    resolve(t.Result);
                }
            }, TaskScheduler.Default);
        }

public static unsafe Task<int>? CallEntrypoint(IntPtr assemblyNamePtr, string?[]? args, bool waitForDebugger)

void SystemInteropJS_AssemblyGetEntryPoint (char *assembly_name, int auto_insert_breakpoint, MonoMethod **method_out)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions