C++ (Qt)QTime time;time.start();while ( notFinished ){ // make some work if ( time.elapsed() > 20 ) // maximum 20 ms for GUI freeze { time.start(); progressBar->update(); QCoreApplication::processEvents(); }}