As the title suggests i need to implement a type of timer based function inside a UI Thread in MFC.
Although CWinThread is a UI Thread and has a message pump it does not have a Timer function as CWnd::OnTimer
Is there any way i can implement a timer based function inside a CWinThread, being also able of course to accept messages coming from other threads?
I tried using a while loop (with or without a Sleep() call) inside CWinThread::Run function but it appears that this technique is preventing the messages to be received. (I've overriden PreTranslateMessage and it's never being called)
I also tried to utilize the CWinThread::OnIdle but the results are kind of the same.
In conclusion there is no way to implement a timer based check inside a CWinThread and be able to receive messages from other threads at the same time.
Or is it?
You could ask me why i do not use a worker thread instead (since i don't actually create any graphical content inside my CWinThread), but i would like to send messages to the thread, and avoid using shared/global variables for communication.
So is there anyway to handle this?
I would like any suggestions.
I hope my description is clear enough.
Thanks in advance!