Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Delay with loop
#2
Yes, you can use an onbect called backgroundworker:
1)Find the backgroundworker from the toolbox and add it to your form
2)Doubleclick the object added
3)In the event that appears add your code(the loop you want)
4)Now when you want to run this loop just use:
Code:
BackgroundWorker1.RunAsynchronousOperation() 'or something similar to it I don't remember it exactly
What did you just do with these actions? You now run the loop in a different thread. So when you use Threading.Thread.Sleep(500) only the thread of the loop freezes and not the entire application. However, notice there is one limitation: you can't edit any object in the form from a different thread. This means that a code like Textbox1.Text="Hello World" would cause a runtime error if it is used from within the BackgroundWorker.

Edit: You can also make your own threads without using the BackgoundWorker, which is much better, but a little more difficult for beginners. If you want to learn about it however, google VB.NET threading
My software company: Porosis Software
Games: Terrantula
Apps: Mathanasis, ColorGrabber
Reply


Messages In This Thread
Delay with loop - by macas5 - 05-19-2010, 06:25 AM
RE: Delay with loop - by thanasis2028 - 05-19-2010, 10:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [VB.Net] Time Delay While Keeping UI Functional (Delegates, StopWatch, Threads) AceInfinity 0 1,069 09-03-2012, 11:19 PM
Last Post: AceInfinity
  Loop through textbox KoBE 0 828 11-17-2010, 03:53 AM
Last Post: KoBE

Forum Jump:


Users browsing this thread: 1 Guest(s)