How to trick Windows into thinking that your application is still busy, although it is not responding

My application is a windows application that executes certain complex mathematical algorithms. Since I started with the application a long time ago, most of them are still single-threaded. To be more precise, the main thread performs all of the complex computational logic. It is important to note that during the calculations I show some progress on the screen.

In most cases, mathematical algorithms take only a few seconds, so after the user has launched this action, an hourglass (or work circle in Windows 7) will appear, and after a few seconds the results will be displayed.

In some cases, the algorithm may take several minutes. During this time, I show the hourglass, and while the algorithm is busy, I show the progress in my window. But, if the user clicks the application after he has been busy for some time, the window becomes “whiter” (as if an opaque piece of plastic is placed above the window), the window is no longer updated, and the application does not respond in Windows reports.

I use Qt and I use the Qt function QWidget :: repaint to force redraw while my algorithm is busy. Repainting works for a while, but as mentioned above, Windows seems to block it after a while.

What is the correct way to tell Windows that your application is still busy so that the window keeps updating? If I enter an explicit message loop, the user can initiate other actions in the application that I do not want.

  • Is PeekMessage enough?
  • Is it enough to call GetMessage?
  • Or do I need to call DispatchMessage? And how can I prevent the user from starting another action (in fact, the ban on entering all users)
  • Do I have to call one of these messages every time I refresh my window, or can I limit myself to call it every few seconds (10 seconds ?, 30 seconds? ...)

Note that moving computation logic to a separate thread is currently not an option.

I am using Visual Studio 2010 on Windows 7 in conjunction with Qt 4.7.

+5
4

DisableProcessWindowGhosting (. http://msdn.microsoft.com/en-us/library/ms648415(v=vs.85).aspx) Windows, "-", .

:

  • , , ( , )
  • , ,... ()
  • : , , .

, .

0

. - . Qt .

, ( execute()), . - Qt Concurrent API .

QtConcurrent::run:

QtConcurrent:: run() . QFuture API.

execute(), , ( A , execute()):

QFuture<void> future = QtConcurrent::run(this, &A::execute);

QFutrureWatcher, .

+5

QApplication::processEvents(), , 2 3 . .

+1

: ,

, , , , , . " "?

+1

All Articles