heres how i use the CreateTimerQueueTimer():
class Timer
{
private:
static unsigned int TimerCount;
PHANDLE m_timerHandle=NULL;
UINT_PTR timerid;
UINT m_uResolution=0;
unsigned int TimerID=0;
unsigned int intInterval=0;
static void CALLBACK TimerProc(void* InstancePointer, BOOLEAN TimerOrWaitFired)
{
Timer* obj=reinterpret_cast<Timer*>(InstancePointer);
if(obj->timerprocedure!=nullptr)
obj->timerprocedure();
}
public:
std::function<void()> timerprocedure=EmptyEvent;
Timer(std::function<void()> tmrprocedure=EmptyEvent)
{
TimerCount++;
TimerID=TimerCount-1;
timerprocedure=tmrprocedure;
}
void Stop()
{
DeleteTimerQueueTimer(NULL, m_timerHandle, NULL);
CloseHandle (m_timerHandle);
}
unsigned int GetInterval()
{
return intInterval;
}
void SetInterval(unsigned int uintInterval)
{
intInterval = uintInterval;
}
property <unsigned int> Interval{GetProperty(Timer::GetInterval),SetProperty(Timer::SetInterval)};
void Start()
{
if(m_timerHandle!=0)
Stop();
if (CreateTimerQueueTimer(m_timerHandle,NULL,TimerProc,reinterpret_cast<PVOID>(this),0,(DWORD)intInterval ,WT_EXECUTEINTIMERTHREAD)==0)
DebugText("error\t" + to_string(GetLastError()));
}
~Timer()
{
if(m_timerHandle!=0)
Stop();
}
};
unsigned int Timer::TimerCount=0;
for now, i only get a memory leak... so what i'm doing wrong?