我可以通过 ajax 关闭监视器并获得响应吗?

发布于 2024-11-29 05:45:25 字数 461 浏览 0 评论 0原文

我正在开发一个网络应用程序,该应用程序将在信息亭上运行并通过触摸屏界面使用。我们想要从管理页面关闭屏幕,因此使用 Windows 电源管理不是一个选项,因为必须明确关闭显示器。

按照这个问题中发布的建议,我能够对我的控制器进行 AJAX 调用,关闭显示器。但是,我的 AJAX 请求从未收到响应,因为 SendMessage() 之后的任何代码都没有执行,我不确定为什么。这超出了我使用 C# 的能力,所以这可能是我不理解的简单事情。 Firebug 显示请求挂起。我尝试单步执行,但是一旦调用 SendMessage(),就不会发生任何其他事情。我还尝试打开监视器(当它打开时),看看是否可以单步执行,但结果是相同的:在 SendMessage() 之后,没有其他任何执行。

那么可以通过 AJAX 来完成并接收响应吗?

I'm working on a web application that will run on a kiosk and used via a touch screen interface. We're wanting to turn off the screen from an administrative page, so using Windows power management isn't an option as turning off the monitor has to be explicitly done.

Following the suggestion posted in this question, I was able to make an AJAX call to my controller and turn the monitor off. However, my AJAX request never receives a response because any code after SendMessage() is not executed and I am unsure as to why. This is venturing beyond my abilities with C#, so it could be something simple that I do not understand. Firebug shows the request hanging. I tried stepping through, but once SendMessage() is called, nothing else happens. I also tried turning on the monitor (while it's on) to see if perhaps I could step through, but the result was the same: after SendMessage(), nothing else executes.

So it is possible to do it via AJAX and receive a response?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葮薆情 2024-12-06 05:45:25

我假设您遵循使用 SendMessage(...) 方法的代码。如果您阅读该问题链接到的文章的底部(http://www.codeproject.com/KB/cs/Monitor_management_guide.aspx),它讨论了一些类似方法之间的行为差​​异:

SendMessage() – 将指定的消息发送到一个或多个窗口,调用指定窗口的窗口过程,直到窗口过程处理完该消息后才返回。
PostMessage() – 在与创建指定窗口的线程关联的消息队列中发布消息并返回,而不等待线程处理消息。

我认为如果您调用 PostMessage(...) 并传递相同的参数,您可能会得到您正在寻找的行为。

I'm assuming you followed the code that uses the SendMessage(...) method. If you read the bottom of the article that was linked to from that question (http://www.codeproject.com/KB/cs/Monitor_management_guide.aspx), it talks about the difference in behavior between a few similar methods:

SendMessage() – Sends the specified message to a window or windows, calls the window procedure for the specified window and does not return until the window procedure has processed the message.
PostMessage() – Posts a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread to process the message.

I think if you call PostMessage(...) passing it the same arguments, you will probably get the behavior you're looking for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文