开发者

Query related to threads in Qt

开发者 https://www.devze.com 2023-01-18 23:41 出处:网络
I want my application to wait indefinitely until a task g开发者_如何学运维ets completed in another thread.

I want my application to wait indefinitely until a task g开发者_如何学运维ets completed in another thread.

How do I perform this in Qt?

On windows, we use waitforsingletonobject, but is there any alternative to this?


Waiting for threads to finish certain tasks (thread synchronization) is the job of the QWaitCondition class.


Call wait on your QThread object.


Use QtConcurrent::run. See my answer to this question. Note that the QFutureWatcher API can work in blocking (the waitForFinished method) and non-blocking (the finished signal) modes.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号