[英]QCoreApplication event loop and Windows Service Control Handler Function
I need both event loops: one for Windows service (or Linux daemon ) and another for Qt event queue QCoreApplication::exec()
(or QApplication::exec()
or even QEventLoop::exec()
). 我需要两个事件循环:一个用于Windows服务 (或Linux守护程序 ),另一个用于Qt事件队列
QCoreApplication::exec()
(或QApplication::exec()
甚至QEventLoop::exec()
)。
Can I have both at the same time in single thread? 我可以同时在单线程中同时拥有这两个吗? Or should I create a separate thread for one of them?
还是应该为其中一个创建单独的线程? In the latter case how should be arranged interaction process between
QObject
s and "window"/"service" thread? 在后一种情况下,应如何安排
QObject
与“窗口” /“服务”线程之间的交互过程?
Windows service requires either Message only window along with window procedure to receive and process a messages from the Windows , or Service Control Handler Function . Windows服务需要“ 仅消息”窗口以及窗口过程来接收和处理来自Windows的消息,或者需要服务控制处理程序功能 。 I want to be able to process both kinds of events comes from the Windows and Qt -specific ones.
我希望能够处理Windows和Qt特有的两种事件。
Can I use QEventLoop/QCoreApplication/QApplication::processEvents
to process Qt events between events, that comes from a Windows ? 我可以使用
QEventLoop/QCoreApplication/QApplication::processEvents
处理来自Windows的事件之间的Qt事件吗? How can it affect service responsiveness and QTimer
responsiveness? 它如何影响服务响应性和
QTimer
响应性?
Qt event loop integrates native notifications/events on all platforms. Qt事件循环在所有平台上集成了本机通知/事件。 The
nativeEventFilter
is how you react to native events when you wish to. nativeEventFilter
是您希望如何响应本机事件的方式。
Try to use QtService library. 尝试使用QtService库。 The QtService is useful for developing Windows services and Unix daemons: https://github.com/qtproject/qt-solutions/tree/master/qtservice
QtService对于开发Windows服务和Unix守护程序很有用: https : //github.com/qtproject/qt-solutions/tree/master/qtservice
Alternatively, you can realize it yourself like as in QtService library: https://github.com/qtproject/qt-solutions/blob/master/qtservice/src/qtservice_win.cpp#L556 或者,您可以像在QtService库中一样自己实现它: https : //github.com/qtproject/qt-solutions/blob/master/qtservice/src/qtservice_win.cpp#L556
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.