Results 1 to 5 of 5

Thread: continuous loop preventing form from displaying

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    115

    continuous loop preventing form from displaying

    i have form1 which kicks off a form2

    in form2 i have a loop which updates a listview

    i want the loop to run continuously until i kill the program (i will eventually add multi-threading but have not yet)

    the loop displays data in a listview, then sleeps then displays next page of data in listview and then restarts from first page

    if i dont have the loop run continuously it works displaying the first page, but once I put it in a do loop without condition i dont see the form2 at all

    it is in the form2 load procedure - so due to the continous loop it never reaches the end sub of the procedure - do u think that is the problem?
    Last edited by jeffnyc; Jul 11th, 2007 at 01:14 PM.

  2. #2
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: continuous loop preventing form from displaying

    are you literally using the sleep command? It pauses all code execution, including form showing. Add a doevents in your loop.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  3. #3
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: continuous loop preventing form from displaying

    Something like that is very likely to soak up all your CPU until the loop gets killed. What's happening is that the loop is running as the form attempts to load, but since the Load event never completes, you never see the form. If you need something to happen constantly, I'd suggest a Timer object. It will allow things to constantly run (up to 64 iterations per second), and it won't soak up a lot of CPU... Plus, it lets background processes happen, where a Do loop will likely take highest priority as it's being debugged and nothing will get done.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    115

    Re: continuous loop preventing form from displaying

    Quote Originally Posted by timeshifter
    Something like that is very likely to soak up all your CPU until the loop gets killed. What's happening is that the loop is running as the form attempts to load, but since the Load event never completes, you never see the form. If you need something to happen constantly, I'd suggest a Timer object. It will allow things to constantly run (up to 64 iterations per second), and it won't soak up a lot of CPU... Plus, it lets background processes happen, where a Do loop will likely take highest priority as it's being debugged and nothing will get done.

    Thanks both of you for your replies.

    I ended up messing with the timer object and it seems to work

    And with the timer object I dont think I even need to make this application multi-threaded.

  5. #5
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: continuous loop preventing form from displaying

    Be careful which timer control you use. Although the icons look exactly the same, they behave differently. And there is a 3rd timer available in .net that isn't on the toolbar which is multi-threaded. Read up on the differences and make sure you use the one that is appropriate for your use.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width