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. Visual Basic
  4. problem in looping:

problem in looping:

Scheduled Pinned Locked Moved Visual Basic
helpcomtoolsquestion
9 Posts 7 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.
  • A Offline
    A Offline
    arp_059
    wrote on last edited by
    #1

    System results in NOT RESPONDING state. I want to have an infinite loop till end button is pressed. Through looping, I want to monitor few files. I used if, for, do, while, until , but none of them resulted in a fruitful way. Can anyone plz help me how I can achieve such looping. Plz help with examples. Thanks in advance. My code can be viewed here: http://www.codeproject.com/script/Forums/View.aspx?fid=1646&msg=2467756[^]

    C M P 3 Replies Last reply
    0
    • A arp_059

      System results in NOT RESPONDING state. I want to have an infinite loop till end button is pressed. Through looping, I want to monitor few files. I used if, for, do, while, until , but none of them resulted in a fruitful way. Can anyone plz help me how I can achieve such looping. Plz help with examples. Thanks in advance. My code can be viewed here: http://www.codeproject.com/script/Forums/View.aspx?fid=1646&msg=2467756[^]

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      arp_059 wrote:

      I want to have an infinite loop till end button is pressed

      Then the loop must go on a different thread. If you loop infinitely then your application will not know about the button press because it is too busy looping to handle events.

      Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

      T 1 Reply Last reply
      0
      • A arp_059

        System results in NOT RESPONDING state. I want to have an infinite loop till end button is pressed. Through looping, I want to monitor few files. I used if, for, do, while, until , but none of them resulted in a fruitful way. Can anyone plz help me how I can achieve such looping. Plz help with examples. Thanks in advance. My code can be viewed here: http://www.codeproject.com/script/Forums/View.aspx?fid=1646&msg=2467756[^]

        M Offline
        M Offline
        MikeMarq
        wrote on last edited by
        #3

        You can create a defacto infinite loop with the timer control. Just drag and drop it into your project and when you set the enable property to true it generates an event periodically. You can then write code in that event to check your file. When you want to stop checking then set the enable property to false.

        1 Reply Last reply
        0
        • A arp_059

          System results in NOT RESPONDING state. I want to have an infinite loop till end button is pressed. Through looping, I want to monitor few files. I used if, for, do, while, until , but none of them resulted in a fruitful way. Can anyone plz help me how I can achieve such looping. Plz help with examples. Thanks in advance. My code can be viewed here: http://www.codeproject.com/script/Forums/View.aspx?fid=1646&msg=2467756[^]

          P Offline
          P Offline
          parth p
          wrote on last edited by
          #4

          How about using Timer control? Not so professional but still it gets the job done. :)

          - Stop thinking in terms of limitations and start thinking in terms of possibilities -

          R 1 Reply Last reply
          0
          • C Colin Angus Mackay

            arp_059 wrote:

            I want to have an infinite loop till end button is pressed

            Then the loop must go on a different thread. If you loop infinitely then your application will not know about the button press because it is too busy looping to handle events.

            Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

            T Offline
            T Offline
            The ANZAC
            wrote on last edited by
            #5

            doesn't application.doevents check if anything else has happened/being pressed etc. I've used it before to put an exit function in a loop from a stop button.

            Please check out my articles: The ANZAC's articles

            C 1 Reply Last reply
            0
            • T The ANZAC

              doesn't application.doevents check if anything else has happened/being pressed etc. I've used it before to put an exit function in a loop from a stop button.

              Please check out my articles: The ANZAC's articles

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              The ANZAC wrote:

              doesn't application.doevents check if anything else has happened/being pressed etc. I've used it before to put an exit function in a loop from a stop button.

              Yes, but you could end up in some terrible recursion problems if you are not careful. The recommended way is to use separate threads.

              Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

              T 1 Reply Last reply
              0
              • C Colin Angus Mackay

                The ANZAC wrote:

                doesn't application.doevents check if anything else has happened/being pressed etc. I've used it before to put an exit function in a loop from a stop button.

                Yes, but you could end up in some terrible recursion problems if you are not careful. The recommended way is to use separate threads.

                Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

                T Offline
                T Offline
                The ANZAC
                wrote on last edited by
                #7

                yeh i'm in agreeance, it really depends on the scale of your application too.

                Please check out my articles: The ANZAC's articles

                1 Reply Last reply
                0
                • P parth p

                  How about using Timer control? Not so professional but still it gets the job done. :)

                  - Stop thinking in terms of limitations and start thinking in terms of possibilities -

                  R Offline
                  R Offline
                  Rajesh Anuhya
                  wrote on last edited by
                  #8

                  Hiii..,,, Keep "Application.doevents" in your infinite loop. then Try. Thanks Rajesh B

                  Rajesh B --> A Poor Workman Blames His Tools <--

                  D 1 Reply Last reply
                  0
                  • R Rajesh Anuhya

                    Hiii..,,, Keep "Application.doevents" in your infinite loop. then Try. Thanks Rajesh B

                    Rajesh B --> A Poor Workman Blames His Tools <--

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    Unless you're REALLY careful about what you're doing, using "DoEvents" in a workaround like this is a dangerous thing to do, causing some very difficult bugs to work out.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007

                    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