void LongQuery(void *addl) { if(WaitForSingleObject(hQueryMutex, 75L) == WAIT_TIMEOUT) { WaitForSingleObject(hScreenMutex, INFINITE); std::cout << "query still running, use 'C' to cancel it." << std::endl; ReleaseMutex(hScreenMutex); return; } try { g_Cmd.setCommandText(LONG_RUNNING_QUERY); WaitForSingleObject(hScreenMutex, INFINITE); std::cout << "executing " << (const char*)g_Cmd.CommandText() << std::endl; ReleaseMutex(hScreenMutex); g_Cmd.Execute(); WaitForSingleObject(hScreenMutex, INFINITE); std::cout << "executed" << std::endl; ReleaseMutex(hScreenMutex); } catch(SAException &x) { WaitForSingleObject(hScreenMutex, INFINITE); std::cout << (const char*)x.ErrText() << std::endl; ReleaseMutex(hScreenMutex); } ReleaseMutex(hQueryMutex); }