Windows如何知道程序没有响应?

how-does-windows-know-a-program-is-not-responding-00

Anyone who has used Windows has seen the occasional system message stating that a program is not responding, but how exactly does Windows know that? Today’s SuperUser Q&A post has the answer to a baffled reader’s question.

使用Windows的任何人都偶尔会看到系统消息,指出程序没有响应,但是Windows到底怎么知道呢? 今天的《超级用户问答》帖子解答了困惑的读者的问题。

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。

Photo courtesy of Matthias Ripp (Flickr).

照片由Matthias Ripp(Flickr)提供

问题 (The Question)

SuperUser reader ArunPrasanth wants to know how Windows knows that a program is not responding:

超级用户阅读器ArunPrasanth想知道Windows如何知道程序没有响应:

How does Windows know if a program is not responding? Does it constantly poll all running applications?

Windows如何知道程序是否没有响应? 它会不断轮询所有正在运行的应用程序吗?

How does Windows know if programs are not responding?

Windows如何知道程序是否没有响应?

答案 (The Answer)

SuperUser contributor ratchet freak has the answer for us:

超级用户贡献者棘轮怪人为我们提供了答案:

An application gets events from a queue provided by Windows. If the application does not poll the event queue for a while (5 seconds), such as doing a long calculation for example, then Windows assumes that the application is hung and alerts the user.

应用程序从Windows提供的队列中获取事件。 如果应用程序在一段时间(5秒)内未轮询事件队列,例如进行长时间的计算,则Windows会假定该应用程序已挂起并向用户发出警报。

To avoid that, applications should push expensive calculations to worker threads or split up processing and make sure the queue gets polled regularly.

为避免这种情况,应用程序应将昂贵的计算推送到工作线程或拆分处理,并确保定期轮询队列。



Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程

翻译自: https://www.howtogeek.com/227568/how-does-windows-know-a-program-is-not-responding/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值