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. Windows and Threads

Windows and Threads

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 4 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.
  • B Offline
    B Offline
    BobInNJ
    wrote on last edited by
    #1

    I have an application that creates several threads. One of these threads creates a (second) Window. When that thread goes away, the window it created goes away also. However, the pointer to the class that represents the window is still valid. It is never freed. I would like the window to stay up when the thread that created it goes away. Is there a reasonable way to do this? Bob P.S. – I am under the impression that there is not.

    B S 2 Replies Last reply
    0
    • B BobInNJ

      I have an application that creates several threads. One of these threads creates a (second) Window. When that thread goes away, the window it created goes away also. However, the pointer to the class that represents the window is still valid. It is never freed. I would like the window to stay up when the thread that created it goes away. Is there a reasonable way to do this? Bob P.S. – I am under the impression that there is not.

      B Offline
      B Offline
      bulg
      wrote on last edited by
      #2

      How'd you figure out that the pointer to the window was still valid?

      B 1 Reply Last reply
      0
      • B BobInNJ

        I have an application that creates several threads. One of these threads creates a (second) Window. When that thread goes away, the window it created goes away also. However, the pointer to the class that represents the window is still valid. It is never freed. I would like the window to stay up when the thread that created it goes away. Is there a reasonable way to do this? Bob P.S. – I am under the impression that there is not.

        S Offline
        S Offline
        Stuart Dootson
        wrote on last edited by
        #3

        BobInNJ wrote:

        I would like the window to stay up when the thread that created it goes away. Is there a reasonable way to do this?

        No. The window requires its WndProc to be on the thread that created it. Each window's messages go via a message queue, which is a per-thread structure.

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        B T 2 Replies Last reply
        0
        • B bulg

          How'd you figure out that the pointer to the window was still valid?

          B Offline
          B Offline
          BobInNJ
          wrote on last edited by
          #4

          Thanks for the response. I claim that the pointer is still valid because it was allocated by doing a new and it was never freeded. It is my understanding that a pointer allocated in one thread, is valid in all threads. Is that wrong? Bob

          1 Reply Last reply
          0
          • S Stuart Dootson

            BobInNJ wrote:

            I would like the window to stay up when the thread that created it goes away. Is there a reasonable way to do this?

            No. The window requires its WndProc to be on the thread that created it. Each window's messages go via a message queue, which is a per-thread structure.

            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

            B Offline
            B Offline
            BobInNJ
            wrote on last edited by
            #5

            Thanks for the response. Bob

            1 Reply Last reply
            0
            • S Stuart Dootson

              BobInNJ wrote:

              I would like the window to stay up when the thread that created it goes away. Is there a reasonable way to do this?

              No. The window requires its WndProc to be on the thread that created it. Each window's messages go via a message queue, which is a per-thread structure.

              Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

              T Offline
              T Offline
              Taran9
              wrote on last edited by
              #6

              Stuart, Isn't message queue an application level data structure that's common to all its threads?

              S 1 Reply Last reply
              0
              • T Taran9

                Stuart, Isn't message queue an application level data structure that's common to all its threads?

                S Offline
                S Offline
                Stuart Dootson
                wrote on last edited by
                #7

                From this page[^]:

                The system maintains a single system message queue and one thread-specific message queue for each graphical user interface (GUI) thread. To avoid the overhead of creating a message queue for non–GUI threads, all threads are created initially without a message queue. The system creates a thread-specific message queue only when the thread makes its first call to one of the User or Windows Graphics Device Interface (GDI) functions.

                Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                T 1 Reply Last reply
                0
                • S Stuart Dootson

                  From this page[^]:

                  The system maintains a single system message queue and one thread-specific message queue for each graphical user interface (GUI) thread. To avoid the overhead of creating a message queue for non–GUI threads, all threads are created initially without a message queue. The system creates a thread-specific message queue only when the thread makes its first call to one of the User or Windows Graphics Device Interface (GDI) functions.

                  Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                  T Offline
                  T Offline
                  Taran9
                  wrote on last edited by
                  #8

                  Thanks for correcting me!

                  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