J
JigglyBit
Guest
Would someone mind giving me some advice on how to keep an interrupt handler running in the background regardless of other messaging that may pop up? I have a task that I am trying to execute with 10 second periodicity and for example if I go to grab the main window header and drag the window (let's say for 20 seconds) I am noticing that all the interrupts being thrown appear to be simply ignored, probably because an event is still in progress. Same thing happens with popup windows. If one is present on screen it seems to block the timer interrupts I have defined. I am not sure if there is a way to do this in a single program thread or if things that need to happen with uninterrupted periodicity should go in a secondary application.
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
float x = 0;
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// Initialize global strings
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadStringW(hInstance, IDC_WINDOWSPROJECT1, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
Sleep(500);
if (!InitInstance(hInstance, nCmdShow))
{
return FALSE;
}
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WINDOWSPROJECT1));
MSG msg;
// Main message loop:
while (TRUE)
{
while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
if (msg.message == WM_TIMER) {
if (msg.wParam == ONE_SECOND_TIMER) { //update graph data cache and redraw
retrieveDataFrame(PointArray);
RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
}
if (msg.wParam == TEN_SECOND_TIMER) { //data logging interval
LogData(sinecounter);
sinecounter++;
}
}
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
if (msg.message == WM_QUIT)
break;
//rest of non-message stuff
//checkForRedraw();
}
return (int) msg.wParam;
}
n simply running this interrupt task and doing nothing else?
Continue reading...
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
float x = 0;
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// Initialize global strings
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadStringW(hInstance, IDC_WINDOWSPROJECT1, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
Sleep(500);
if (!InitInstance(hInstance, nCmdShow))
{
return FALSE;
}
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WINDOWSPROJECT1));
MSG msg;
// Main message loop:
while (TRUE)
{
while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
if (msg.message == WM_TIMER) {
if (msg.wParam == ONE_SECOND_TIMER) { //update graph data cache and redraw
retrieveDataFrame(PointArray);
RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
}
if (msg.wParam == TEN_SECOND_TIMER) { //data logging interval
LogData(sinecounter);
sinecounter++;
}
}
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
if (msg.message == WM_QUIT)
break;
//rest of non-message stuff
//checkForRedraw();
}
return (int) msg.wParam;
}
n simply running this interrupt task and doing nothing else?
Continue reading...