The most annoying window in Visual Studio :: Can you turn this off?

  • (2 Pages)
  • +
  • 1
  • 2

27 Replies - 1156 Views - Last Post: 22 September 2018 - 04:42 PM

#16 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: The most annoying window in Visual Studio :: Can you turn this off?

Posted 21 September 2018 - 11:36 AM

Useful link Modi, but I don't need help debugging. I know how to debug, but what I don't know how to do is stop that annoying window when i do pause the lot. Took you a while there to see what I was getting at. Sometimes when you debug, and your code finishes executing, you need to pause it to access the code again. Lets say, you have a button, and you set break points on it, but while you let it execute, it brings you back to your app and out of the editor. This is when I pause it all, and get the annoying window. Did I miss something you are trying to point out here?

Off to see the nun in cinema, will check in laters to see if there is a fix to my annoyance. :)

Thanks for your replies.
Was This Post Helpful? 0
  • +
  • -

#17 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15116
  • View blog
  • Posts: 60,494
  • Joined: 12-June 08

Re: The most annoying window in Visual Studio :: Can you turn this off?

Posted 21 September 2018 - 11:41 AM

No, your process doesn't make sense. I break point my code. Run it. Step through what I need, investigate what I need, amd stop it. I have never had to use 'break all'.
Was This Post Helpful? 0
  • +
  • -

#18 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6798
  • View blog
  • Posts: 28,102
  • Joined: 12-December 12

Re: The most annoying window in Visual Studio :: Can you turn this off?

Posted 21 September 2018 - 03:42 PM

I am still puzzled.

Quote

Sometimes when you debug, and your code finishes executing, you need to pause it to access the code again.

If your code has finished executing how could you pause it?

The only thing that occurs to me is that perhaps you are are talking about a long running process that you have to interrupt?

Otherwise, to pursue this further, I think you will have to describe steps to recreate the issue starting with a basic app.

Added: Just revisited your original screenshot and noticed the word Arduino. I suspect this has some relevance.
Was This Post Helpful? 0
  • +
  • -

#19 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6969
  • View blog
  • Posts: 23,686
  • Joined: 05-May 12

Re: The most annoying window in Visual Studio :: Can you turn this off?

Posted 21 September 2018 - 08:51 PM

Oh, I think I know what's happening. Sheepings is trying to actually use the Visual Studio feature called Edit and continue.

Repro steps:
1. Create a simple WinForms project.
2. Paste in the following code into Program.cs.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;

namespace SimpleWinForms
{
    class MyForm : Form
    {
        public MyForm()
        {
            MessageBox.Show("We've only just begun.");

            var lblTime = new Label()
            {
                AutoSize = false,
                Location = new Point(10, 10),
                Size = new Size(100, 60)
            };
            Controls.Add(lblTime);

            var timer = new Timer();
            timer.Interval = 1000;
            timer.Tick += (o, e) => lblTime.Text = DateTime.Now.ToString("yyyy-MM-dd\r\nH:MM:ss tt");
            timer.Start();
        }
    }

    static class Program
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MyForm());
        }
    }
}


3. Press F5 to run.
4. Click OK on "We've only just begun" message box.
5. Press Ctrl-Break to go into "Break Mode".

Results:
In Visual Studio, focus is changed to another tab. Depending on symbol loading options and "Show my code only", the page displayed varies. If Source Server support is enabled along with Windows Symbol Server enabled, there is a high probability of being taken to a line of .NET Framework code. If "Show my code only" enabled, it may display like the original post.

Expected results:
Stay on the Program.cs editor tab.

If he got his expected results, he could simply edit line 27 on Program.cs and press F5 and the program looks to pick up from where it left off. He wouldn't see the "We've only just begun" message box again.
Was This Post Helpful? 2
  • +
  • -

#20 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6969
  • View blog
  • Posts: 23,686
  • Joined: 05-May 12

Re: The most annoying window in Visual Studio :: Can you turn this off?

Posted 21 September 2018 - 09:02 PM

Personally, I don't use the "Edit and continue" feature. Call me old fashioned. If I do any kind of edit, I want a full build to happen and for my unit tests to run before my program runs from the beginning again.
Was This Post Helpful? 1
  • +
  • -

#21 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: The most annoying window in Visual Studio :: Can you turn this off?

Posted 22 September 2018 - 06:34 AM

Your some techy for one techy Skydiver, :) you know, that is exactly what is happening, and those are settings I use sometimes. But do you happen to know if there is a way to stop the annoying window from popping up? If not, I may have to create my own VS extension to interrupt the window call from launching. I was rather hoping there is a simple option, but with the hundreds of people on SO, all complaining of the same thing, I'm assuming there is no simple option to knock this off?

What I don't get is why Microsoft put this annoying window in there in the first place. It's obvious I've paused the debugger, so why on earth do i need a window telling me the same thing. If only Microsoft realised how inconvenient this window is, they'd disable it in the last VS release.

This post has been edited by Sheepings: 22 September 2018 - 06:34 AM

Was This Post Helpful? 0
  • +
  • -

#22 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6969
  • View blog
  • Posts: 23,686
  • Joined: 05-May 12

Re: The most annoying window in Visual Studio :: Can you turn this off?

Posted 22 September 2018 - 08:34 AM

I think that the misunderstanding stems from not knowing what "Break All" does. Breaking into the program stops the program exactly* at the instruction being run at the time. Since the program stops there, the debugger then tries it's very best to show you exactly where that CPU instruction is at. So if you have Windows symbols and sources features enabled, then you'll get something that looks like this:
Attached Image
This exactly what any hardcore Microsoft developer wants to see. And since Microsoft developers generally have access to both publicly available Windows/.NET source code as well as the internal only source code, they get a great debugging experience. It was this great debugging experience that the DevDiv team had to sell to the rest of the company so that developers would internally actually use Visual Studio instead of the old practice which was to use WinDBG as debugger, and then use their editor of choice: Source Insight, emacs, CodeWright, etc., and may there would be an occasional Visual Studio user.

Of course for most everybody, the default setting of "My Code Only", you get the ugly experience where the debugger tries to bring you as close to the stopped instruction. Unless your code is stuck inside an infinite loop somewhere in your code, then the debugger will end up be somewhere inside the message pump. The default message pump code is in the .NET Framework and won't satisfy the "My Code only" setting, so the debugger has to keep climbing up the callstack until it can find a piece of your code. See this callstack with symbols for reference:
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(ref System.Windows.Forms.NativeMethods.MSG msg) Line 3621
	at f:\dd\ndp\fx\src\winforms\Managed\System\WinForms\Application.cs(3621)
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(ref System.Windows.Forms.NativeMethods.MSG msg) Line 3763
	at f:\dd\ndp\fx\src\winforms\Managed\System\WinForms\Application.cs(3763)
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) Line 2135
	at f:\dd\ndp\fx\src\winforms\Managed\System\WinForms\Application.cs(2135)
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) Line 3426
	at f:\dd\ndp\fx\src\winforms\Managed\System\WinForms\Application.cs(3426)
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Line 3306
	at f:\dd\ndp\fx\src\winforms\Managed\System\WinForms\Application.cs(3306)
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) Line 1493
	at f:\dd\ndp\fx\src\winforms\Managed\System\WinForms\Application.cs(1493)
SimpleWinForms.exe!SimpleWinForms.Program.Main() Line 39
	at M:\z\Test\SimpleWinForms\SimpleWinForms\Program.cs(39)


Unfortunately, the next available stack frame that is within your code will be Program.cs, and you get the annoying window.

*Actually at the next available user mode instruction. Only the kernel debugger will stop at the instruction within kernel mode.
Was This Post Helpful? 1
  • +
  • -

#23 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: The most annoying window in Visual Studio :: Can you turn this off?

Posted 22 September 2018 - 12:05 PM

Thanks for the explanation Sky, but where do you conclude that I don't know what break all does?

I don't mean to come across rude, but I didn't post this question for people to assume how much I know about debugging or to dive into a full-blown debugging discussion. All I wanted to know is if people understood what I asked, and if it can be turned off. None-the-less your answer is clear, and thanks for your replies.
Was This Post Helpful? 0
  • +
  • -

#24 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15116
  • View blog
  • Posts: 60,494
  • Joined: 12-June 08

Re: The most annoying window in Visual Studio :: Can you turn this off?

Posted 22 September 2018 - 12:22 PM

It cycles back to you seem to be fighting something that is working 'as intended'. If you 'break all' when a program is idle VS needs to indicate where the code execution is paused - and, in the example above, it's at the "application.run". That's what is showing in the call stack.

You can test this out by in the bottom of your constructor throw this in.

            for (int i = 0; i < 1000000000; i++)
            {
                Console.WriteLine(i);
            }


When your app runs, hit the break all and see it stop in the console like because that's what's on the call stack.

Posted Image

The implied alternative is to skip using 'break all' and just use individual break points. Less the wrecking ball approach when a finishing hammer would do.
Was This Post Helpful? 0
  • +
  • -

#25 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6969
  • View blog
  • Posts: 23,686
  • Joined: 05-May 12

Re: The most annoying window in Visual Studio :: Can you turn this off?

Posted 22 September 2018 - 01:50 PM

Sheepings: I didn't mean to imply that you didn't know how to debug. I was just trying to explain why the behavior exists.

It sounds like your expected behavior is that if you break into the program, your preference is that Visual Studio not try to show you exactly where in the code the break happened. You would rather have VS simply bring you back into the "Editing" state rather than be in a "Debugging" state. (As far as I know there is no way to do that. That Visual Studio extension just seems to be a hack, although I've not actually looked into its source code to see what it does.)

The most that I can suggest to minimize the disruption between "Editing" and "Debugging" is layout all your window panes to be exactly the same regardless of which state you are in. After than, while in the "Editing" state, double click on "Program.cs" to add it to your list of open source file tabs in your Editing panes. That way when you do press F5 to run, and later Ctrl-Break into your program, VS will take you to Program.cs in a screen layout that looks like you are still editing. Then the important thing: Do not close out that "Program.cs" pane. Simply click on the tab of the other code that you intended to touch as part of your "Edit and continue" workflow.
Was This Post Helpful? 0
  • +
  • -

#26 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: The most annoying window in Visual Studio :: Can you turn this off?

Posted 22 September 2018 - 04:07 PM

View Postmodi123_1, on 22 September 2018 - 08:22 PM, said:

It cycles back to you seem to be fighting something that is working 'as intended'.

I am not fighting it modi123_1. I hoped for a way to manipulate or change it. I would like to see an option for less intrusive notifications as to what is currently executing. Example, I'd like to see a clickable link in the ouput tab, when clicked, it would open the tab and bring you to the required line number. An option for that would be preferred by me.

View PostSkydiver, on 22 September 2018 - 09:50 PM, said:

your expected behavior is that if you break into the program, your preference is that Visual Studio not try to show you exactly where in the code the break happened.

Not quite, only when the application is idle, because it is always going to be Application.Run(new Form1()); unless something else is executing, I'd prefer not to know.

And what you said in your last reply Sky, that's what I do, or if I know I've reached the end of execution, and I need to rerun it, I just bang in a new break point and restart the debugger to avoid the popping window.
Was This Post Helpful? 0
  • +
  • -

#27 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6969
  • View blog
  • Posts: 23,686
  • Joined: 05-May 12

Re: The most annoying window in Visual Studio :: Can you turn this off?

Posted 22 September 2018 - 04:23 PM

You could try marking the Main() with DebuggerNonUserCode or DebuggerHidden attributes and see if it gives you a better behavior...
Was This Post Helpful? 0
  • +
  • -

#28 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: The most annoying window in Visual Studio :: Can you turn this off?

Posted 22 September 2018 - 04:42 PM

Nice article Sky, but I don't step over, as I want to know what all of my code is doing, even the properties and simple value assigning etc. I think the only reason I hate the popup so much is because I write code on a laptop which is not exactly the quickest, and the popup causes a bit of a hang when it happens. :) But I will look into this a bit more

Something I'll have to tolerate i guess.

This post has been edited by Sheepings: 22 September 2018 - 04:44 PM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2