Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with worker thread

Problem with worker thread

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ashtwin
    wrote on last edited by
    #1

    Hi, i am using multithreading in my application. I want to use MFC object(view and MainFrame object) in my worker thread. Can anybody tell how to do this. Thanks.

    D M J T 4 Replies Last reply
    0
    • A ashtwin

      Hi, i am using multithreading in my application. I want to use MFC object(view and MainFrame object) in my worker thread. Can anybody tell how to do this. Thanks.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      What do you mean by "use?" Worker threads (i.e., those without a message pump) should not interact with UI components other than to post a message to the component's owner. The owner is therefore responsible for updating the UI component.


      "One must learn from the bite of the fire to leave it alone." - Native American Proverb

      1 Reply Last reply
      0
      • A ashtwin

        Hi, i am using multithreading in my application. I want to use MFC object(view and MainFrame object) in my worker thread. Can anybody tell how to do this. Thanks.

        M Offline
        M Offline
        Marc Soleda
        wrote on last edited by
        #3

        From within your worker thread you have a handle to its parent. Using this handle you'll be able to use/interact with this MFC object. Marc Soleda. ... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits. -- modified at 10:46 Thursday 8th September, 2005

        1 Reply Last reply
        0
        • A ashtwin

          Hi, i am using multithreading in my application. I want to use MFC object(view and MainFrame object) in my worker thread. Can anybody tell how to do this. Thanks.

          J Offline
          J Offline
          Jim Howard
          wrote on last edited by
          #4

          No, you don't want to use your view and mainframe objects in a worker thread. That will cause a disaster of biblical proportions. Those objects belong to the GUI thread. The way your work thread will interact with the GUI is by passing the thread a pointer to the view or mainframe window, and then posting messages to this window. Go to flounder.com and read Dr Newcomber's articles on threading.

          1 Reply Last reply
          0
          • A ashtwin

            Hi, i am using multithreading in my application. I want to use MFC object(view and MainFrame object) in my worker thread. Can anybody tell how to do this. Thanks.

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            ashtwin wrote: . I want to use MFC object(view and MainFrame object) in my worker thread. Can anybody tell how to do this. you will find this article intresting :)- http://www.codeproject.com/threads/usingworkerthreads.asp[^]

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups