[quote=87520:@Thom McGrath]How an object is created has no bearing at all on how its code is executed. All events are just methods. Timer actions get called as part of the main event loop, and no other way. If the timer had a Poll method, you could force the timer to run in a thread, but it doesn’t, so you can’t.
As for why you’re seeing different results, I have no idea. I can’t figure how a thread would ever help animation speed. Either your calculations take less time than it takes for a frame to expire, or it doesn’t. A thread won’t have any impact on that.[/quote]
Ok I have no doubts that what you say is correct about Xojo, but I know the period difference occurs because Windows is not a real-time operating system (Except Windows CE…yet Linux and Mac are :-/), which is why the variability in period occurs…and I understand that WM_Timer messages are all sent to the same window message queue via the dispatch created in the entrypoint…as all messages are. I don’t remember the exact specifics given by the engineering professor why it works (was almost 7 years ago)…but I will ask him via email and get back as to why a timer created by a thread reacts differently (on windows) than created from the main itself. Either way, it’s great Xojo performs exactly as expected, if I had sat down in-front of a notepad and C++…that is finesse on the Xojo developer’s part
I learn something new everyday about Xojo
So Xojo pretty much does what my S++ compiler does to handle timers under-the-hood…
dword Timer1;
Timer1 = 1000; //just random identifier
dword Timer1_Period;
dword Timer1_Mode;
frame Window1.Events.Handler(dword hwnd,dword message,dword wparam,dword lparam);
if (message = WM_TIMER){
if (wparam = Timer1){if (Timer1.Mode = 1){Timer1_Action();KillTimer(Window1.hwnd,Timer1);}if (Timer1.Mode = 2){Timer1_Action();}}
}
DefWindowProc(hwnd,message,wparam,lparam);
end;
property set Timer1.Mode(dword ModeValue);
dword Timer1_Mode;
Timer1_Mode = ModeValue;
if (ModeValue = 0){KillTimer(Window1.hwnd,Timer1);}
if (ModeValue = 1){SetTimer(Window1.hwnd,Timer1,Timer1.Period,NULL);}
if (ModeValue = 2){SetTimer(Window1.hwnd,Timer1,Timer1.Period,NULL);}
end;
property get Timer1.Mode() as dword;
return(Timer1_Mode);
end;
property set Timer1.Period(dword IntervalValue);
Timer1_Period = IntervalValue;
if (IntervalValue = 0){Timer1.Mode = 0;
}else{
SetTimer(Window1.hwnd,Timer1,Timer1_Period,NULL);
}
end;
property get Timer1.Period() as dword;
return(Timer1_Period);
end;
frame Timer1_Action();
//Code to perform during the interval
end;