Losing messages between threads

  • Hello,
    I am running a single application on WinCE, with several threads. One thread is dedicated to my serial comms, where I receive data regularly at about 10Hz. From this thread I use PostThreadMessage with a (WM_APP + X) command to tell my main thread to process the data received serially and then display the corresponding info. The main thread is running in a message loop, waiting on GetMessage().


    My problem is that the message to the main thread sometimes gets removed before the process functions are called (NB: the PostThreadMessage does not return 0). My understanding is that threads are initially created without a queue, however, by using the GetMessage function, a queue is created, and if not, the PostThreadMessage function would return 0.


    Is that correct or do I have to use CreateMsgQueue (which I thought was only necessary between processes)? How can I find out how large my message queue is and what messages are on the queue?


    Many thanks,
    Sarah

  • Hello,
    another very simple suggestion for your purpose:
    write and read the serial data into a circular buffer and lock this buffer using a critical section while do read/write access.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.