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. Get out of infinite loop question!

Get out of infinite loop question!

Scheduled Pinned Locked Moved C / C++ / MFC
questionperformance
4 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.
  • J Offline
    J Offline
    jazzkiller
    wrote on last edited by
    #1

    Hi all, I am writing a program that continuously stores data from an external memory. while(isConnected) { // Do stuff over here }// end while However, when it runs, it takes all the memory (program is not responded). I have another button (Stop) to call method to set isConnected to False in order to get out of the loop. However, I didn't even have a chance to hit that button because the program is freezed. Any suggestions? Thanks.

    P A T 3 Replies Last reply
    0
    • J jazzkiller

      Hi all, I am writing a program that continuously stores data from an external memory. while(isConnected) { // Do stuff over here }// end while However, when it runs, it takes all the memory (program is not responded). I have another button (Stop) to call method to set isConnected to False in order to get out of the loop. However, I didn't even have a chance to hit that button because the program is freezed. Any suggestions? Thanks.

      P Offline
      P Offline
      PJ Arends
      wrote on last edited by
      #2

      http://www.codeproject.com/threads/usingworkerthreads.asp[^]


      "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!


      Honoured as one of The Most Helpful Members of 2004

      1 Reply Last reply
      0
      • J jazzkiller

        Hi all, I am writing a program that continuously stores data from an external memory. while(isConnected) { // Do stuff over here }// end while However, when it runs, it takes all the memory (program is not responded). I have another button (Stop) to call method to set isConnected to False in order to get out of the loop. However, I didn't even have a chance to hit that button because the program is freezed. Any suggestions? Thanks.

        A Offline
        A Offline
        Aneurysm00
        wrote on last edited by
        #3

        Use a worker thread. If you don;t thread the application, then the reason you're locking the program up is because the Message Loop never has the chance to run, and therefore the button press is never noticed. Use a thread for the user interface, and one to do the loop.

        1 Reply Last reply
        0
        • J jazzkiller

          Hi all, I am writing a program that continuously stores data from an external memory. while(isConnected) { // Do stuff over here }// end while However, when it runs, it takes all the memory (program is not responded). I have another button (Stop) to call method to set isConnected to False in order to get out of the loop. However, I didn't even have a chance to hit that button because the program is freezed. Any suggestions? Thanks.

          T Offline
          T Offline
          Tim Smith
          wrote on last edited by
          #4

          An alternative is to pump the message queue every n iterations of the loop. There is no need to create a worker thread. Tim Smith I'm going to patent thought. I have yet to see any prior art.

          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