473,508 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sleep?

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
7 21985
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
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
"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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
13959
by: Anks | last post by:
hi I am displaying a digital clock in an applet.I am using Thread.sleep (1000) for counting every second.This works fine some times but some times my clock just slows down or give an...
7
10210
by: Colin Brown | last post by:
Python 2.3.3 Under Windows NT: Negative Int or Real -> sleeps for a long time Under Linux: Returns IOError: Invalid argument I consider both of these unfriendly results and expected the...
5
5521
by: Dave | last post by:
For the life of me, I thought there was a sleep() function in the Standard Library (or something similarly named), but I can't find it. Is it non-existent or, if not, what header is it in? ...
21
18651
by: Alo Sarv | last post by:
Hi From what I have understood from various posts in this newsgroup, writing event loops pretty much comes down to this: while (true) { handleEvents(); sleep(1); // or _sleep() or...
8
2767
by: Cider123 | last post by:
I ran into a situation where my Window Service had to process 100,000+ files, when I first noticed I needed to tweak various routines. Everything runs fine, but here's what I ran into: In the...
9
3473
by: Chris Dunaway | last post by:
According to the docs, calling Thread.Sleep(0) causes the thread to be "suspended to allow other waiting threads to execute." What happens if I call Thread.Sleep(500)? Do other threads not get a...
17
6389
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. ...
1
2759
by: Matt Brown - identify | last post by:
Hello, I, as well as suspecting many others, am having an issue when I attempt to enter sleep mode in Vista. If any program is connected to the internet (AOL Instant Messenger for instance),...
13
5786
by: Charles Zhang | last post by:
Sleep() function Sleep at lease 1 millisecond, there is a way to make a thread to sleep less than a millisecond? One way I know of is using performance counter which is not really sleep ( loop and...
0
1389
by: Tim Golden | last post by:
Lowell Alleman wrote: Well you've certainly picked a ticklish area to run into problems with ;). First, forget about the threading aspects for the moment. AFAICT the smallest program which...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.