Disable pause after execution 2

z l 0 Reputation points
2025-01-09T19:09:28.4033333+00:00

What happened to the first post where I asked this question?

Why are there still these puzzle verifications when posting?

--

It's been asked for years, and I was wondering if something has finally been done about it.

I'd like after an execution of a c++ console app without debugging (ctrl+f5) not to be required to press a key to continue.

Why? Since I also execute from a shortcut, and then I have a behavior when sometimes it waits and sometimes it doesn't, and the inconsistency throws me off.

Why not run with debugging (f5)? Since then, when I want to go over the code while it's running, I need to detach the debugger.

Since you haven't changed it in years, and you probably never will, can you at least explain the reason for this behavior? One would have thought that if a debugger is attached, then VS is watching, and then pauses after execution, and not the other way around.


A related issue. When executing without debugging, it seems that VS is still "watching." I have this issue:

https://drive.google.com/file/d/1Q1L2z6d7mYIwVu_oIpnKtuK2fd6hN-5z/view?pli=1

Can you explain how VS is still watching without being attached?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,339 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 55,841 Reputation points
    2025-01-09T19:31:31.46+00:00

    The behavioral change for console apps was made because if you run a console app without any breakpoints then any output displayed at the end of the program will go away before you can read it, if applicable. Since this is a common thing the console window behavior was modified to pause at the end so you can review any final output from the program before closing it yourself. Alternatively you just ignore the window and you can start debugging again and it'll auto-close the last window, effectively.

    As you mentioned, the only time this might be problematic is if you're starting the debugger and another program is waiting for the program to terminate. The easiest thing to do is to just close the window since this is when the app actually terminates. But if you don't want this behavior and are OK disabling it across the board then go to Tools \ Options -> Debugging \ General. Find the setting called Automatically close the console window... and check the box. You'll be back to the old approach.

    User's image

    I'm not aware of a per-project option for this.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.