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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Is "Create window in Work thread" a bad design?

Is "Create window in Work thread" a bad design?

Scheduled Pinned Locked Moved C / C++ / MFC
designc++helpquestionlearning
4 Posts 3 Posters 1 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.
  • F Offline
    F Offline
    fitatc
    wrote on last edited by
    #1

    My friend "Create window in Work thread" when she need a message pump (message loop? I am not sure, sorry I am a beginner). She just create a window, and then do a loop like WndProc does. :confused:I am also worry about if it could work I know that MFC has a UI thread that with a message Pump can do this without creating a window. But I cannot persuade she to use UI thread instead of a "Work thread with window", because of my pity knowledge :( . could any one help me about that.

    _ J 2 Replies Last reply
    0
    • F fitatc

      My friend "Create window in Work thread" when she need a message pump (message loop? I am not sure, sorry I am a beginner). She just create a window, and then do a loop like WndProc does. :confused:I am also worry about if it could work I know that MFC has a UI thread that with a message Pump can do this without creating a window. But I cannot persuade she to use UI thread instead of a "Work thread with window", because of my pity knowledge :( . could any one help me about that.

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      The only difference between a UI thread and a worker thread is that a UI thread has a message loop. So what your friend has created is a UI thread rather than a worker thread.

      «_Superman_»

      1 Reply Last reply
      0
      • F fitatc

        My friend "Create window in Work thread" when she need a message pump (message loop? I am not sure, sorry I am a beginner). She just create a window, and then do a loop like WndProc does. :confused:I am also worry about if it could work I know that MFC has a UI thread that with a message Pump can do this without creating a window. But I cannot persuade she to use UI thread instead of a "Work thread with window", because of my pity knowledge :( . could any one help me about that.

        J Offline
        J Offline
        Joshua Tully
        wrote on last edited by
        #3

        There's an article on this site that discusses worker and UI threads and here you go http://www.codeproject.com/KB/threads/usinguithreads.aspx[^]

        F 1 Reply Last reply
        0
        • J Joshua Tully

          There's an article on this site that discusses worker and UI threads and here you go http://www.codeproject.com/KB/threads/usinguithreads.aspx[^]

          F Offline
          F Offline
          fitatc
          wrote on last edited by
          #4

          Thanks for answer my qustion, «_Superman_» and Josh_Jackson :laugh: I trace to the source code of the CWinThread into thrdcore.cpp. (1) CWinThread is derived from CCmdTarget, That bring to CWinThread the Message_Map so it can get message from OS???:confused: (2) If so Why CWinThread need a CWnd in UINT APIENTRY _AfxThreadEntry(void* pParam)

          UINT APIENTRY _AfxThreadEntry(void* pParam)
          {
          .....
          CWnd threadWnd;
          TRY
          {
          .... if (pApp != NULL &&
          pThread->m_pMainWnd == NULL && pApp->m_pMainWnd->GetSafeHwnd() != NULL)
          {
          // just attach the HWND
          threadWnd.Attach(pApp->m_pMainWnd->m_hWnd);
          pThread->m_pMainWnd = &threadWnd;
          }

          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