QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
QgsThreadingUtils Class Reference

Provides threading utilities for QGIS. More...

#include <qgsthreadingutils.h>

Static Public Member Functions

template<typename Func >
static bool runOnMainThread (const Func &func, QgsFeedback *feedback=nullptr)
 Guarantees that func is executed on the main thread.
 

Detailed Description

Provides threading utilities for QGIS.

Since
QGIS 3.4

Definition at line 119 of file qgsthreadingutils.h.

Member Function Documentation

◆ runOnMainThread()

template<typename Func >
static bool QgsThreadingUtils::runOnMainThread ( const Func &  func,
QgsFeedback feedback = nullptr 
)
inlinestatic

Guarantees that func is executed on the main thread.

If this is called from another thread, the other thread will be blocked until the function has been executed. This is useful to quickly access information from objects that live on the main thread and copying this information into worker threads. Avoid running expensive code inside func. If a feedback is provided, it will observe if the feedback is canceled. In case the feedback is canceled before the main thread started to run the function, it will return without executing the function.

Note
Only works with Qt >= 5.10, earlier versions will execute the code in the worker thread.
Since
QGIS 3.4

Definition at line 140 of file qgsthreadingutils.h.


The documentation for this class was generated from the following file: