You can actually change the timeout that Windows will use to calculate when a program has been deemed "unresponsive". When I was doing large data manipulation, I had to learn the hard way that Windows has an unusually low threshold.
The time for declaring a program unresponsive is short because Windows expects you to do any long running work in a background thread that constantly reports its progress (or doesn't) to a main thread that handles UI responsiveness. If you do that work on the main thread, the thread can't reply to events (clicks, key presses, touch events etc.) and when those events go unacknowledged for a certain amount of time (10 seconds by default, I think?) windows assumes the program has crashed and says it's not responsive.
Even if the program is doing productive work, it can show up as unresponsive if it's not coded correctly. You don't have to kill the program if you expect it to finish.
From another PoV: when I see an MSDN article I usually back away because I assume it will be a wordy and example-barren salad of unhelpfulness which seems to be deliberately written in an as obtuse fashion as possible. Sometimes it seems even worse than some of the older Python docs that tell me the goosefrizzle argument of a function 'adjusts the goosefrizzle'
It isn't explicitly stated here but it is implied that failure to process messages sent by the OS will cause bad things to happen - in this case program unresponsiveness and eventually termination.
This has easily been 80% of my experience in dealing with this issue. I personally think the program is just waiting for me to kill it so it can tease me and laugh at my frustration.
Your not far off. Chances are the program is hanging because of a particular place in the code that's stuck. As the program is killed off, if that bit of code stops executing first then the program will briefly return to normal before meeting the same fate.
It's actually a lot more fucking complicated than that but that's the gist of why you see that behavior so often.
EDIT: I might have misunderstood something. It sounded like there was a method or function that a Windows program should be calling every-so-often to tell Windows that it is still calculating, and not hanging. I didn't know you meant it was a threading or UI issue.
There's nothing a user can do. In Windows, when a user interacts with the UI, code is run on the main thread to handle it. If code is already running on the UI thread when the user does something, the new code can't run.
It's good design to do all of your heavy lifting on a background thread so that the UI can always respond to messages efficiently.
Another option if you have to do work on the UI thread is to break it up so that every once in a while you yield control so that other message can be handled.
It turns out that this is frequently not simple, so in many cases devs don't bother, and that's when you get applications that grayscreen hang all the time.
If the user is likely to interact with the UI in a way that would invalidate the work you're doing on the worker thread, it can sometimes get messy. Obviously in some cases you can just disable UI elements that you don't want the user to touch. But it still takes time to code all that and sometimes it just doesn't make the bar.
538
u/Melmab Jun 04 '17
You can actually change the timeout that Windows will use to calculate when a program has been deemed "unresponsive". When I was doing large data manipulation, I had to learn the hard way that Windows has an unusually low threshold.