protected async Task ConnectAndStartRunLoopAsync( Uri uri, Func <string, CancellationToken, Task> receive, CancellationTokenSource cts) { WasmDebuggerConnection conn = await SetupConnection(uri, cts.Token); conn.OnReadAsync = receive; _runLoop = new(new[] { new DevToolsQueue(conn) }, logger); _runLoop.RunLoopStopped += (sender, args) => RunLoopStopped?.Invoke(sender, args); _ = _runLoop.RunAsync(cts); }
protected async Task RunLoopAsync(WasmDebuggerConnection ideConn, WasmDebuggerConnection browserConn, CancellationTokenSource cts) { try { this.ide = new DevToolsQueue(ideConn); this.browser = new DevToolsQueue(browserConn); ideConn.OnReadAsync = ProcessIdeMessage; browserConn.OnReadAsync = ProcessBrowserMessage; _runLoop = new(new[] { ide, browser }, logger); _runLoop.RunLoopStopped += RunLoopStopped; await _runLoop.RunAsync(cts); } finally { _runLoop?.Dispose(); _runLoop = null; } }