I'm working on this one:
Code:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <inttypes.h>
#define TIMER1 0
#define TIMER2 1
typedef void (*f_ptr)();
void CALLBACK action1(HWND hwnd, UINT uMsg, UINT timerId, DWORD dwTime){
printf("action1\n");
}
void CALLBACK action2(HWND hwnd, UINT uMsg, UINT timerId, DWORD dwTime){
printf("action2\n");
}
f_ptr fptr1;
f_ptr fptr2;
int i = 0;
int main()
{
MSG msg1, msg2;
fptr1 = action1;
fptr2 = action2;
SetTimer(NULL,TIMER1,1000,(TIMERPROC)fptr1);
SetTimer(NULL,TIMER2,500,(TIMERPROC)fptr2);
while(i < 3){
if(GetMessage(&msg1, NULL, 0, 0)) { DispatchMessage(&msg1); }
i++;
}
while(1){
if(GetMessage(&msg2, NULL, 0, 0)) { DispatchMessage(&msg2); }
}
return 0;
}
Why the first while loop doesn't break or stop, I put a condition for its termination.
Loop 2 should run forever, but I thought loop 1 should break.