示例#1
0
文件: step7.cpp 项目: kzinti/revok
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);
}