Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey guys does anyone know a way to make a delay in vb.net ?

is there any method that does that ?

i tried to do something with timer but unsuccesfully.

here is what i need

 

i have a sequence of functions which i need to run in specific time order

say:

function1

wait 5 seconds

function 2

wait 2 seconds

function 3

etc ..

 

i need something that will be stable not for example a for loop.

 

thanks guys, any example will be very helpfull

Posted

guys thanks

normaly it works but i need to use it also within a loop and for some reason it doesn't work - the program halts and return results after it's out of the loop - , any other ideas ?

  • Leaders
Posted

maybe something like this.

Dim f as Integer '// number of functions to use.
Dim i as Integer
For  i = 1 to f
'/// do the function
System.Threading.Thread.Sleep ' time to sleep
Next i

not tried it , but it seems logical ( and a similar principle works fine in vb6 )

Posted
guys thanks

normaly it works but i need to use it also within a loop and for some reason it doesn't work - the program halts and return results after it's out of the loop - , any other ideas ?

me too:

i use this code:

Private Sub geefAntwoord_Click()
 antwoord.SetFocus
 status.Caption = "goede antwoord: " + antwoorden(current)
 Sleep 1000
 status.Caption = ""
End Sub

it has to work in this order:

1) status gets the caption "goede antwoord: "

2) wait 1 sec.

3) Clear the status

 

but what it does is:

1)wait a sec.

2) set status to "goede antwoorden" and clear it at once so you can't see it

  • 4 weeks later...
Posted

Just the info I needed :)

 

maurad3r,

could what you are seeing be a result of windows not painting the status bar (or something along those lines). That's a poke in the dark for me, thought it may help...

 

Cheers,

Matt

  • 2 weeks later...
Posted

Try adding a DoEvents

 

Try adding the .NET version of a DoEvents before the sleep statement:

 

Private Sub geefAntwoord_Click()

antwoord.SetFocus

status.Caption = "goede antwoord: " + antwoorden(current)

System.Windows.Forms.Application.DoEvents()

Sleep 1000

status.Caption = ""

End Sub

 

Cant be sure it will work but its worth a try.

Guest
This topic is now closed to further replies.
×
×
  • Create New...