tags:

views:

47

answers:

1

Hi, I have created a UI thread. I m posting message to the UI thread which will write data in a file.

I m using PostThreadMessage API to post the message to User thread

My Problem is it's not writing all the data that i have posted.

For Instance, if i post 100 data, it writes randomly 3 or 98 varies for every execution.

The handler for Postdata is not getting called for every message.

CWriteToFile *m_pThread = (CWriteToFile *)AfxBeginThread(RUNTIME_CLASS (CWriteToFile));

PostThreadMessage(m_pThread->m_nThreadID , WM_WRITE_TO_FILE, (WPARAM)pData,NULL);

WaitForSingleObject(m_pThread, INFINITE);

Note: The Return value of Post is success

Thanks in Advance.

A: 

The PostMessage family of functions can fail if the message queue is full. You should check whether or not the function call succeeds.

yngvedh