Can I turn off a monitor via ajax and get a response?
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?
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.
精彩评论