Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Timer thread in C Ask Question. Asked 1 year, 3 months ago. Active 1 year, 3 months ago. Viewed times. I'm coding in C on Ubuntu.
I need to write a timer thread in C. What can I do about? Thanks to all in advance. Improve this question. What you are trying to do is a widely used concept. Check out what other people are doing: stackoverflow. I don't know how to implement it though, i'm a bit rusty on threads. I don't recommend changing thread priorities. I'm not sure what your case is Thanks for the reply "Codeplug", When you run my code, you can see that the Code:.
Originally Posted by evariste. If you have an idea on how to do this feel free to answer me. Replies: 0 Last Post: , AM. This requires a component similar to a timer. This component is called in windows. The first step is of course to set up a Timer. The window must be controlled by the thread that created the timer.
If this parameter is an existing timer ID, this timer will replace it. The hwnd member of the MSG structure of the sent message contains the hWnd parameter. If the function succeeds, the return value is the ID of the new timer.
You can use this ID to delete the Timer. If the function fails, the return value is 0, call GetLastError to get more error information. Another window can have its own timer, and the ID can be the same as the timer ID of other windows. But the timer itself is unique. In multiple threads of a process, each thread has its own independent message queue.
But this leads to a problem: Many times the thread that creates the timer does not want it to be blocked, because this may be our job Thread.
0コメント