Q:

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()).
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 QObjects and "window"/"service" thread?
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. I want to be able to process both kinds of events comes from the Windows and Qt-specific ones.
Can I use QEventLoop/QCoreApplication/QApplication::processEvents to process Qt events between events, that comes from a Windows? How can it affect service responsiveness and QTimer responsiveness?

A:

Try to use QtService library. The QtService is useful for developing Windows services and Unix daemons:
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

