Hello! Tell me who has any ideas how to solve. There is a console application. It performs various calculations in separate threads. It is necessary to organize user break. That is, by pressing Esc , the calculations and the application are completed. So far there are two ideas, SetWindowsHookEx (...) and boost :: signal .
1 answer
As the simplest option:
#include <windows.h> int main() { for ( ; ; ) { // ... вычисления ... if ( GetAsyncKeyState( VK_ESCAPE ) & 0x8000 ) { // ... // подготовка к выходу // ... break; } // ... вычисления ... } return 0; } In fact, it all depends on the needs. Quite possibly, the SetWindowsHookEx option would be more appropriate.
- I asked a question, then I remembered for this function. Already done. GetAsyncKeyState is enough to solve the problem. Anyway, many thanks for the answer and interest in the question. - jaroslav
|