It can be done without `deferToThread`, with Qt signals, a `QTimer` and a slot that checks the condition from the `while`.