How can I make my VB .Net program sleep for 5 minutes?

  • Thread starter Thread starter Roger Solano
  • Start date Start date
R

Roger Solano

How can I make my VB .net program sleep or pause for say 5 minutes?

Any help would be much appreciated.

Roger
 
Herfried K. Wagner said:
'System.Threading.Thread.Sleep(5000)'.

I think it's in milliseconds so 5 minutes would be
'System.Threading.Thread.Sleep(300000)' 'three hundred thousand ms.
 
Ricky
I think it's in milliseconds so 5 minutes would be
'System.Threading.Thread.Sleep(300000)' 'three hundred thousand ms.

You know how fast Herfried is he post in a second what another does in a
minute.

:-)

Cor
 
Roger,

In additon to the others,

When you do this than mostly is adviced to use a timer or to use a different
thread. Because your program stops completly and your user cannot even
cancel it in a normal way.

An easy way to prevent that freezing is
For i = 1 to 300
threading.thread.sleep(i * 1000)
application.doevents
next
 
* "Ricky W. Hunt said:
I think it's in milliseconds so 5 minutes would be
'System.Threading.Thread.Sleep(300000)' 'three hundred thousand ms.

Ooops. I mixed up 5 minutes with 5 seconds...
 
Herfried K. Wagner said:
Ooops. I mixed up 5 minutes with 5 seconds...

Herfried, what does a program actually "do" during this sleep time? Is it
consuming any resources other than memory?
 
I wrote this, maybe make 50 more... like 100 or so

Sub Pause(ByVal pmTimeToPause As Double)

Dim iIndex As Int16
For iIndex = 1 To pmTimeToPause / 50
If g_bEnd = True Then Exit Sub

System.Threading.Thread.CurrentThread.Sleep(50)
Application.DoEvents()

Next

End Sub

1§ 1§
 
* "Ricky W. Hunt said:
Herfried, what does a program actually "do" during this sleep time? Is it
consuming any resources other than memory?

It still uses its resources, but it doesn't get any processor time. So
the UI will be "locked" in this time.
 
Back
Top