Simple time delay in vb.net?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Simple time delay in vb.net?

  1. #1
    Join Date
    Aug 2007
    Posts
    5

    Question Simple time delay in vb.net?

    Forgive me if this is a really dumb question (or if this has been covered here before) -- but is there a way to do a simple time delay in vb.net?

    I've done a bit of scripting with Applescript, and the syntax there for a five second delay would simply be:

    delay 5

    Is there a method like this in vb.net? I'd much rather use a single line of code like this, than have to mess around with creating a timer, and then coding a function for it to call to. But if that's the only way...

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    System.Threading.Thread.Sleep
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Feb 2004
    Posts
    808
    Bear in mind that if you call this on the GUI thread (the thread that create the main window of your app) then the app will "hang" for 5 seconds.. ThHis might not be a concern for you, but if it is, then youll need to run your work on a separate thread
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  4. #4
    Join Date
    Aug 2007
    Posts
    5
    Quote Originally Posted by cjard
    Bear in mind that if you call this on the GUI thread (the thread that create the main window of your app) then the app will "hang" for 5 seconds..
    That is exactly what I would like the app to do... thanks so much to both of you, this is perfect!

  5. #5
    Join Date
    Oct 2009
    Posts
    1
    i tried creating a program that changed the text property of a text box then delayed for 2 seconds then changed the text property again. this is my code
    Label1.Text = "try again"
    System.Threading.Thread.Sleep(2000)
    Label1.Text = "what is your name?"
    my problem is that this only creates the delay whilst displaying the second piece of text.

    any solutions?

  6. #6
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Try refreshing the label before the delay:

    Label1.Text = "try again"
    Label1.Refresh
    System.Threading.Thread.Sleep(2000)
    Label1.Text = "what is your name?"
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. query tuning
    By dhaya in forum Database
    Replies: 11
    Last Post: 08-25-2003, 05:24 PM
  2. A moderate view.
    By Paul Mc in forum .NET
    Replies: 214
    Last Post: 06-01-2001, 07:27 AM
  3. Do REAL VB programmers want VB.NET?
    By Gary Nelson in forum .NET
    Replies: 154
    Last Post: 03-26-2001, 02:05 PM
  4. VB.NET: 3 points of view
    By David Kroll in forum .NET
    Replies: 33
    Last Post: 02-13-2001, 10:23 PM
  5. Replies: 84
    Last Post: 01-29-2001, 01:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center