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. Mobile Development
  3. Mobile
  4. Using a thread in a dialog project

Using a thread in a dialog project

Scheduled Pinned Locked Moved Mobile
question
7 Posts 2 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.
  • I Offline
    I Offline
    illidan99
    wrote on last edited by
    #1

    Hi, I need to use the same thread for several Dialogs. I do it for one dialog and it works, because I associate it with this dialog. But If I want to use it in another dialog, ¿How can I do it? How can I associate it with several dialogs? Another question: How Can I use a member class dialog variable in another Dialog code? Thanks. Regards, Javier

    J 1 Reply Last reply
    0
    • I illidan99

      Hi, I need to use the same thread for several Dialogs. I do it for one dialog and it works, because I associate it with this dialog. But If I want to use it in another dialog, ¿How can I do it? How can I associate it with several dialogs? Another question: How Can I use a member class dialog variable in another Dialog code? Thanks. Regards, Javier

      J Offline
      J Offline
      Joao Paulo Figueira
      wrote on last edited by
      #2

      That may be a questionable programming practice. Isn't there any other place where you can put that variable that is accessible to all dialogs? Regards, João Paulo Figueira Embedded MVP

      I 1 Reply Last reply
      0
      • J Joao Paulo Figueira

        That may be a questionable programming practice. Isn't there any other place where you can put that variable that is accessible to all dialogs? Regards, João Paulo Figueira Embedded MVP

        I Offline
        I Offline
        illidan99
        wrote on last edited by
        #3

        Yes, sorry, I only need two variables managed in the thread that they could be accessible from all dialogs, and I need to resume or to stop the thread from a button in any dialog. How can I do it? I only need to know to make accessibles threads variables(or member variables) or something else. Regards. Regards, Javier

        J 1 Reply Last reply
        0
        • I illidan99

          Yes, sorry, I only need two variables managed in the thread that they could be accessible from all dialogs, and I need to resume or to stop the thread from a button in any dialog. How can I do it? I only need to know to make accessibles threads variables(or member variables) or something else. Regards. Regards, Javier

          J Offline
          J Offline
          Joao Paulo Figueira
          wrote on last edited by
          #4

          Try a global object. Not a clean solution, but works. Regards, João Paulo Figueira Embedded MVP

          I 1 Reply Last reply
          0
          • J Joao Paulo Figueira

            Try a global object. Not a clean solution, but works. Regards, João Paulo Figueira Embedded MVP

            I Offline
            I Offline
            illidan99
            wrote on last edited by
            #5

            ok, what is the clean solution? If I do it like global object, how can i define it?Any sample or code for learn it? Thank you. Regards, Javier

            J 1 Reply Last reply
            0
            • I illidan99

              ok, what is the clean solution? If I do it like global object, how can i define it?Any sample or code for learn it? Thank you. Regards, Javier

              J Offline
              J Offline
              Joao Paulo Figueira
              wrote on last edited by
              #6

              illidan99 wrote: ok, what is the clean solution? Language purists don't like globals... that's all. I regularly use globals and it's very easy to do. I create two files, one named "globals.h" that is included in all cpp files that need to access the global variables. For instance:

              #ifndef __GLOBALS__
              #define __GLOBALS__

              extern int g_nInteger;
              extern HANDLE g_hThread;

              #endif

              Now, you include in your project a cpp file named "globals.cpp":

              #include "stdafx.h"
              #include "globals.h"

              int g_nInteger = 0;
              HANDLE g_hThread = NULL;

              And that's all you need. Regards, João Paulo Figueira Embedded MVP

              I 1 Reply Last reply
              0
              • J Joao Paulo Figueira

                illidan99 wrote: ok, what is the clean solution? Language purists don't like globals... that's all. I regularly use globals and it's very easy to do. I create two files, one named "globals.h" that is included in all cpp files that need to access the global variables. For instance:

                #ifndef __GLOBALS__
                #define __GLOBALS__

                extern int g_nInteger;
                extern HANDLE g_hThread;

                #endif

                Now, you include in your project a cpp file named "globals.cpp":

                #include "stdafx.h"
                #include "globals.h"

                int g_nInteger = 0;
                HANDLE g_hThread = NULL;

                And that's all you need. Regards, João Paulo Figueira Embedded MVP

                I Offline
                I Offline
                illidan99
                wrote on last edited by
                #7

                ok, thank you Regards, Javier

                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