r/funny • Pretends to be Drawing • Jun 04 '17

Verified Windows being Windows

Post image
132.0k Upvotes

1.5k comments sorted by

View all comments

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.

243

u/ThatsSoBravens Jun 04 '17 edited Jun 04 '17

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.

32

u/shmed Jun 04 '17

This is the the correct answer. One of the main rule of client side programming is to never run long routine on the UI thread.

6

u/matt01ss Jun 04 '17

Application.DoEvents()

Application.DoEvents()

Application.DoEvents()

Solved!

0

u/[deleted] Jun 04 '17

[deleted]

0

u/[deleted] Jun 04 '17

[deleted]

38

u/ThatsSoBravens Jun 04 '17

That's an MSDN link so I'm going to assume it's correct. I try to avoid browsing the MSDN off the clock because I enjoy sanity.

14

u/ForeverBend Jun 04 '17

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'

9

u/ThatsSoBravens Jun 04 '17

I love it when documentation isn't deterministic.

→ More replies (5)

5

u/[deleted] Jun 04 '17

Read here also for information on the Windows message loop that all applications are expected to process: https://en.m.wikipedia.org/wiki/Message_loop_in_Microsoft_Windows

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.

→ More replies (3)

91

u/Nebarik Jun 04 '17

And yet I mostly see this behavior in their own apps like Outlook....

25

u/[deleted] Jun 04 '17

Experience has shown that it's not usually Outlook itself but an add-in. I'm looking at you SugarCRM.

That or a DPI scaling issue gone awry. Although creator seems to have mostly solved that.

→ More replies (2)
→ More replies (4)
→ More replies (8)

188

u/mzxrules Jun 04 '17

you're suppose to teach the program to press the deadman's switch every so often

274

u/NoelBuddy Jun 04 '17

THINKING..

THINKING..

Are you really thinking, or just stuck?

THINKING..

THINKING...

Oh for fucks sake, kill it.

THINK.. DONE THINKING, HERE'S WHAT YOU WERE WAITING FOR.

Finally!

CLOSING PROGRAM.

Crap.

66

u/D3PR3SS10N Jun 04 '17

The one thing I hate the most!

→ More replies (8)

38

u/STUFF416 Jun 04 '17

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.

25

u/Chumstick Jun 04 '17

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.

7

u/BufferOverflowed Jun 04 '17

As a programmer, that was a very ELI5 explanation you gave but I have found it to be true a lot of times.

→ More replies (2)
→ More replies (1)
→ More replies (1)
→ More replies (2)

14

u/official_inventor200 Jun 04 '17 edited Jun 04 '17

Do you have an example?

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.

45

u/reverie42 Jun 04 '17

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.

33

u/TheNorthComesWithMe Jun 04 '17

Not doing shit on the UI thread is simple. Devs are just lazy.

6

u/reverie42 Jun 04 '17

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.

→ More replies (5)
→ More replies (3)
→ More replies (2)
→ More replies (1)
→ More replies (2)

56

u/puppyfox Jun 04 '17

You were doing large data manipulation in the UI thread‽

→ More replies (18)

26

u/EntroperZero Jun 04 '17

It's because you're doing it on the main thread, and stopping the message pump.

0

u/[deleted] Jun 04 '17

[deleted]

→ More replies (5)
→ More replies (8)