Wait function

  • Thread starter Thread starter kuldeepiitk
  • Start date Start date
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
 
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
 
Back
Top