Important: Please read the Qt Code of Conduct -

General question on asynchronous programming

  • Hi,
    Though it is a general question, I am mostly encountering the issue while learnnig Qt.

    Let me give a simple example. Let's say I want to continue a process if and only if three mututally exclusive asynchronous processes (say, A, B and C) have succeeded. If anyone of them fails, I want to stop. If these three processes where not asynchronous, I could run them one after the other as make my decision to continue or not. however, this is not the case for the asynchronous processes A, B and C.

    What I would like to know is: "What is the standard design (or QT's) pattern of going about this?".

    I would appreciate an example or any external references to follow up on.


  • To be clear, are you talking about processes or threads?

  • Thanks for clarifying this. Looking at the documentation for QNetworkAccessManager, for example, Qt says "QNetworkAccessManager has an asynchronous API". I would rather use this definition just so to be within the context of Qt's best practices.

  • If you are talking abuot the asynchronous API of Qt classes, they usually emit signals that indicate success/fail.
    For example, QTcpSocket will emit a connected signal once a connection has been established.

    So if you're question is, how do I synchronize my code with Qt asynchronous function calls, my answer would be connect to the appropriate signals.

Log in to reply