time delay

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

how do i insert a time delay of 30second ?

how do i show on the window form the timedelay? e.g i want it to tick 1
second by 1 second to show in the window form
 
Newbie,

Most people do it this way
\\\
threading.thread.sleep(30000)
///

Some people do it this way
\\\
Imports system.threading
..
..
..
Thread.sleep(30000)
///

I find that not nice.

Cor
 
newbie said:
how do i insert a time delay of 30second ?

how do i show on the window form the timedelay? e.g i want it to tick 1
second by 1 second to show in the window form

Add a 'System.Windows.Forms.Timer' to your form. Then insert this code:

\\\
Private m_StartTime As Date
Private m_MinutesToWait As Integer = 2
..
..
..
With Me.Timer1
.Interval = 400
.Enabled = True
End With
m_StartTime = Now()
..
..
..
Private Sub Timer1_Tick( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Timer1.Tick
Dim ts As TimeSpan = Now().Subtract(m_StartTime)
If ts.TotalMinutes >= m_MinutesToWait Then
Me.Timer1.Enabled = False
MsgBox("Timer fired!")
End If
Me.Text = ts.TotalSeconds.ToString()
End Sub
///
 
Newbie,

I did not see your second question.

\\\
For i as integer = 1 to 30
Threading.thread.Sleep(1000)
label1.text = i.toString
label1.show
application.doevents
next
///

Sorry

Cor
 

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

Back
Top