Click to See Complete Forum and Search --> : Update views from an worker thread


Stefano Magni
March 29th, 1999, 08:45 AM
Hi all,


I'm writing an application that have a worker thread : this thread read data from a serial port; at the end of this thread I must update the views of my program. I call the function "CDocument::UpdateAllViews" from my thread but the application generate an application-error.

How can I update the views from my worker thread ?


Thanks in advance for your answer.

Dazza
March 29th, 1999, 09:49 AM
Try posting a user-defined message to the main application window, and creating a message handler (maybe in the document itself) for that message that calls CDocument::UpdateAllViews. This will ensure that UpdateAllViews is called by the main application thread rather than the worker thread.

sangli
April 21st, 1999, 07:19 AM
For the above proposed solution, If the worker thread throws a user-defined message, how to map so that member function of document is called. If I use AfxGetApp->SendMessage(), then only WinApp derived class can map the message...?

Is there any other way.. thanks for any help.!

April 21st, 1999, 08:24 AM
You can use AfxGetMainWnd()->SendMessage() to send it to the FrameWnd and handle
the message in the frameWnd. In the handler call UpdateAllviews fn. This will solve the pbm I think.
--Mythili

April 30th, 1999, 05:02 AM
This is failing in release version, why? Mail me at dineshsv@hotmail.com. Thank you.

Waiting for reply
Dinesh