简体   繁体   English

QCoreApplication事件循环和Windows服务控制处理程序功能

[英]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. 我希望能够处理WindowsQt特有的两种事件。

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.

相关问题 由于QCoreApplication事件循环,QThread永不退出 - QThread never quits due to QCoreApplication event loop 如何在其他类的嵌套循环内进入主事件循环QCoreApplication来实现网络操作? - How to get to the main event loop QCoreApplication within nested loops of other classes for implementing networking operations? 如何使用QCoreApplication :: winEventFilter处理Windows消息 - How to Handle Windows Messages using QCoreApplication::winEventFilter 将数据传递到Windows控制台控制处理程序 - Passing Data to Windows Console Control Handler Windows服务SERVICE_WIN32_OWN_PROCESS运行Qt 5.10事件循环的方法 - Windows service SERVICE_WIN32_OWN_PROCESS running Qt 5.10 event loop howto 在事件处理程序回调中调用模块函数 - Call module function in event handler callback 具有Bind()的wxButton的事件处理函数-wxWidgets 3.0 - Event handler function to wxButton with Bind() - wxWidgets 3.0 io_service如何将完成事件与完成处理程序匹配 - How io_service matches a completion event with a completion handler 尝试实现Windows API包装器的事件处理程序时遇到问题 - Having trouble when trying to implement a Event Handler for Windows API wrapper 为什么我的Windows控制台关闭事件处理程序超时? - Why does my Windows Console Close Event Handler time out?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM