public async Task Initialize(MICore.WaitLoop waitLoop, CancellationToken token) { bool success = false; Natvis.Initialize(_launchOptions.VisualizerFile); int total = 1; await this.WaitForConsoleDebuggerInitialize(token); try { await this.MICommandFactory.EnableTargetAsyncOption(); List<LaunchCommand> commands = GetInitializeCommands(); total = commands.Count(); var i = 0; foreach (var command in commands) { token.ThrowIfCancellationRequested(); waitLoop.SetProgress(total, i++, command.Description); if (command.IsMICommand) { Results results = await CmdAsync(command.CommandText, ResultClass.None); if (results.ResultClass == ResultClass.error && !command.IgnoreFailures) { string miError = results.FindString("msg"); throw new UnexpectedMIResultException(command.CommandText, miError); } } else { await ConsoleCmdAsync(command.CommandText); } } success = true; } finally { if (!success) { Terminate(); } } waitLoop.SetProgress(total, total, String.Empty); token.ThrowIfCancellationRequested(); }