Wait function

K

kuldeepiitk

Is there any way that i can make my application wait for some time so
that page loads in that time, right now I am using following code,

=================================
Public Sub waitBySecs(ByVal nNumSecs As Integer)
Dim d1, d2 As DateTime

d1 = DateTime.Now.AddSeconds(nNumSecs)
d2 = DateTime.Now

While DateTime.Compare(d2, d1) < 0
Application.DoEvents()
d2 = DateTime.Now
End While
End Sub
====================================

but the problem in this function is that it takes the whole CPU usage,
so I am looking for an alternative for it.

TIA
~kuls
 
M

M. Zeeshan Mustafa

put
Threading.Thread.Sleep(100)
before
End While

this will make execution to sleep (wait) 100 milliseconds
before going back to While...

--
Hope this helps,
Zeeshan Mustafa, MCSD


kuldeepiitk said:
Is there any way that i can make my application wait for some time so
that page loads in that time, right now I am using following code,

=================================
Public Sub waitBySecs(ByVal nNumSecs As Integer)
Dim d1, d2 As DateTime

d1 = DateTime.Now.AddSeconds(nNumSecs)
d2 = DateTime.Now

While DateTime.Compare(d2, d1) < 0
Application.DoEvents()
d2 = DateTime.Now
End While
End Sub
====================================

but the problem in this function is that it takes the whole CPU usage,
so I am looking for an alternative for it.

TIA
~kuls
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top