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. Suspending an application with out using Sleep()

Suspending an application with out using Sleep()

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

    I have an application MyApp which spawns 2 process A and B. MyApp cannot communicate to either A or B. MyApp first starts the process A and It has to wait untill A has completed initilization and reaches a stable state which is approx 4 mins. MyApp should remain idle during this time period. After 4 min, MyApp starts process B and should wait for approx 2 min and shutdown. What is the best method for suspending MyApp for the above said duration using very little system resources? I do not want to use Sleep() for this purpose.

    J M L M 4 Replies Last reply
    0
    • K koumodaki

      I have an application MyApp which spawns 2 process A and B. MyApp cannot communicate to either A or B. MyApp first starts the process A and It has to wait untill A has completed initilization and reaches a stable state which is approx 4 mins. MyApp should remain idle during this time period. After 4 min, MyApp starts process B and should wait for approx 2 min and shutdown. What is the best method for suspending MyApp for the above said duration using very little system resources? I do not want to use Sleep() for this purpose.

      J Offline
      J Offline
      Justin Perez
      wrote on last edited by
      #2

      I am unsure if this applys to you, but have you considered WaitForSingleObject()?

      I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")

      1 Reply Last reply
      0
      • K koumodaki

        I have an application MyApp which spawns 2 process A and B. MyApp cannot communicate to either A or B. MyApp first starts the process A and It has to wait untill A has completed initilization and reaches a stable state which is approx 4 mins. MyApp should remain idle during this time period. After 4 min, MyApp starts process B and should wait for approx 2 min and shutdown. What is the best method for suspending MyApp for the above said duration using very little system resources? I do not want to use Sleep() for this purpose.

        M Offline
        M Offline
        Maxwell Chen
        wrote on last edited by
        #3

        Use the Event?! WaitForSingleObject(..., 4 minutes, ...).


        Maxwell Chen

        1 Reply Last reply
        0
        • K koumodaki

          I have an application MyApp which spawns 2 process A and B. MyApp cannot communicate to either A or B. MyApp first starts the process A and It has to wait untill A has completed initilization and reaches a stable state which is approx 4 mins. MyApp should remain idle during this time period. After 4 min, MyApp starts process B and should wait for approx 2 min and shutdown. What is the best method for suspending MyApp for the above said duration using very little system resources? I do not want to use Sleep() for this purpose.

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          koumodaki wrote:

          I do not want to use Sleep()

          Why not it suspends the thread using very little system resources and so meets your requirements? :confused:

          D 1 Reply Last reply
          0
          • L led mike

            koumodaki wrote:

            I do not want to use Sleep()

            Why not it suspends the thread using very little system resources and so meets your requirements? :confused:

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

            Perhaps he's afraid that he'll forget to set the alarm and oversleep.


            "A good athlete is the result of a good and worthy opponent." - David Crow

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            1 Reply Last reply
            0
            • K koumodaki

              I have an application MyApp which spawns 2 process A and B. MyApp cannot communicate to either A or B. MyApp first starts the process A and It has to wait untill A has completed initilization and reaches a stable state which is approx 4 mins. MyApp should remain idle during this time period. After 4 min, MyApp starts process B and should wait for approx 2 min and shutdown. What is the best method for suspending MyApp for the above said duration using very little system resources? I do not want to use Sleep() for this purpose.

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              If your app has a UI, and it stays visible during the waiting period, then you could disable the main window for the duration.  Set a one-shot timer to wake it. If there's no UI or you hide the app's UI while it's waiting then there's no reason to Sleep() - it won't be doing anything.  You still need a way to wake it though. Mark

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              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