My assignment is to do serial port communications with the Modbus protocol.
I already wrote a Read thread and a Write thread. The readthread is a threadfunction in the main process and the write thread is derived from CWinThread.

The tasks the program should perform are:
1)Send Modbus status request to serial port (Write thread)
2)Wait for response to arrive at the serial port (Read thread)
3)Send Modbus value request to serial port (Write thread)
4)Wait for response to arrive at the serial port (Read thread)

These tasks are to be performed repeatedly, every 2 or 3 secs.
The problem is in the synchronisation between the threads. I now use a timer that fires every 2 secs and place the calls to the threads inside the OnTimer(). This all works fine, however it makes only sense to start reading after the request has been done and the threads can not use more time than 2 secs, otherwise a new timerevent is fired. What is the best way to do this? Some advice would be welcome.