diff --git a/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs b/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs index 9276a5d..f4adf8c 100644 --- a/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs +++ b/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs @@ -41,6 +41,7 @@ public class DebuggingService process.Start(); var debugProtocolHost = new DebugProtocolHost(process.StandardInput.BaseStream, process.StandardOutput.BaseStream, false); + var initializedEventTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); _debugProtocolHost = debugProtocolHost; debugProtocolHost.LogMessage += (sender, args) => { @@ -62,6 +63,10 @@ public class DebuggingService { ; }); + debugProtocolHost.RegisterEventType(@event => + { + initializedEventTcs.SetResult(); + }); debugProtocolHost.RegisterEventType(async void (@event) => { await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding); // The VS Code Debug Protocol throws if you try to send a request from the dispatcher thread @@ -117,6 +122,8 @@ public class DebuggingService } }; debugProtocolHost.SendRequestSync(attachRequest); + // AttachRequest -> HandshakeRequest -> InitializedEvent + await initializedEventTcs.Task; foreach (var breakpoint in breakpointsByFile) {