CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Stefano Magni Guest

    Update views from an worker thread



    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.

  2. #2
    Join Date
    Apr 1999
    Posts
    24

    Re: Update views from an worker thread



    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.



  3. #3
    Join Date
    Apr 1999
    Posts
    3

    Re: Update views from an worker thread

    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.!




  4. #4
    Guest

    Re: Update views from an worker thread

    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


  5. #5
    Guest

    Re: Update views from an worker thread

    This is failing in release version, why? Mail me at [email protected]. Thank you.

    Waiting for reply
    Dinesh


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured