|
-
Jul 11th, 2007, 01:11 PM
#1
Thread Starter
Lively Member
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.
-
Jul 11th, 2007, 01:17 PM
#2
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.
-
Jul 11th, 2007, 01:17 PM
#3
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.
-
Jul 11th, 2007, 02:31 PM
#4
Thread Starter
Lively Member
Re: continuous loop preventing form from displaying
 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.
-
Jul 11th, 2007, 07:10 PM
#5
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|