By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,702 Members | 1,496 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,702 IT Pros & Developers. It's quick & easy.

sleep?

P: n/a
I'm new to VB.Net. Wondering how you do a sleep for x milliseconds and then
continue executing on the next line? This was done in VB6 and wondering how
it's done in VB.Net.
Feb 13 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
guy
look at:-
System.Threading.Thread.CurrentThread.Sleep( )

hth

--guy--

"HockeyFan" wrote:
I'm new to VB.Net. Wondering how you do a sleep for x milliseconds and then
continue executing on the next line? This was done in VB6 and wondering how
it's done in VB.Net.

Feb 13 '06 #2

P: n/a
System.Threading

Imports System.Threading

public sub mySub

'do something before waiting
Thread.Sleep(2000) ' sleeps for 2000 milliseconds
'do something after waiting

end sub

Can get you in trouble if you have multiple threads unless you are
careful.

Feb 13 '06 #3

P: n/a
"guy" <gu*@discussions.microsoft.com> schrieb:
System.Threading.Thread.CurrentThread.Sleep( )


Better simply call 'System.Threading.Thread.Sleep', which will block
execution of the thread calling the method.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Feb 13 '06 #4

P: n/a
CMM
I don't remember this being available in VB6?!
I know you could do it using the Win32 Sleep API... but it wasn't part of
VB6.

--
-C. Moya
www.cmoya.com
"HockeyFan" <Ho*******@discussions.microsoft.com> wrote in message
news:DD**********************************@microsof t.com...
I'm new to VB.Net. Wondering how you do a sleep for x milliseconds and
then
continue executing on the next line? This was done in VB6 and wondering
how
it's done in VB.Net.

Feb 13 '06 #5

P: n/a
Imports System

Public Module modmain

Sub Main()

Console.WriteLine("I wait five seconds")

System.Threading.Thread.Sleep(5000)

Console.WriteLine("five seconds have passed")

End Sub

End Module

regards

Michel Posseth [MCP]



"CMM" <cm*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I don't remember this being available in VB6?!
I know you could do it using the Win32 Sleep API... but it wasn't part of
VB6.

--
-C. Moya
www.cmoya.com
"HockeyFan" <Ho*******@discussions.microsoft.com> wrote in message
news:DD**********************************@microsof t.com...
I'm new to VB.Net. Wondering how you do a sleep for x milliseconds and
then
continue executing on the next line? This was done in VB6 and wondering
how
it's done in VB.Net.


Feb 15 '06 #6

P: n/a
CMM
VB6?

The .NET answer had already been posted. I was asking about the OT
mentioning VB6.

--
-C. Moya
www.cmoya.com
Feb 15 '06 #7

P: n/a
well in my newsgroup reader the .Net answer wasn`t showed i see now that
this was on a seperate thread
about the vb6 thingy

afaik this can only be done like this

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Command1_Click()

Me.Caption = "Your system will sleep 5 sec."

'Sleep for 5000 milliseconds

Sleep 5000

Me.Caption = ""

End Sub

Private Sub Form_Load()

Me.Caption = ""

Command1.Caption = "Sleep ..."

End Sub

regards

Michel Posseth [MCP]
"CMM" <cm*@nospam.com> wrote in message
news:OD**************@TK2MSFTNGP11.phx.gbl...
VB6?

The .NET answer had already been posted. I was asking about the OT
mentioning VB6.

--
-C. Moya
www.cmoya.com

Feb 15 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.