Form object "Not Responding" if program launched without Debugger RRS feed

  • Question

  • I encountered this issue recently and not sure where to start looking. My program uses a form to track various runtime statistics for a production tester. Every few seconds, during a break in the program, I send it updated information to populate on the form and then Refresh() the form. 

    In debug mode, everything works fine. When I release to the production tester (either using VSProj installer or by copying the binaries locally), the Form will almost immediately stop responding after I create it. I can replicate this in Visual Studio by Running Without Debugger. 

    What approach should I be looking at to get this working? It is inconvenient and impractical to have VS running in the background when production is using the software, however that seems to be the only way that I have found to get it to work. Any referrals to similar issues would be helpful. 

    Wednesday, August 28, 2019 6:00 PM

All replies

  • Hello,

    What code is executing during the freezing? You could use Task.Delay

    public async Task<string> DemoTask()
        int count = 0;
        while (true)
            var message = $"Chatty Writer number {count}";
            await Task.Delay(500);
        return "";

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Wednesday, August 28, 2019 6:22 PM
  • How do you define "during a break in the program"?  Are you doing your statistics gathering in your main thread, or do you have a separate thread?

    To a certain extent, I'm grasping at straws here, but I suspect that's the stage you've reached.  If you have a tight CPU loop in your main thread, that would cause the UI to go unresponsive.  Perhaps the presence of the debugger is hiding some of that.

    Tim Roberts | Driver MVP Emeritus | Providenza &amp; Boekelheide, Inc.

    Wednesday, August 28, 2019 6:46 PM
  • I send it updated information to populate on the form and then Refresh() the form.

    How you do that is important. If you are accessing the form from a thread different from the thread that created it (probably the main thread) then that is not supported; it is fundamental to the way Windows works. It is something that can work but not guaranteed to work. So that can explain the inconsistency.

    Sam Hobbs

    Wednesday, August 28, 2019 9:06 PM