My Threading Timer Doesn't Fire

  • Thread starter Thread starter Daniel Maycock via .NET 247
  • Start date Start date
D

Daniel Maycock via .NET 247

I can't get my threading timer to show a splash screen panel for six seconds, then move onto the next panel. The timer just doesn't tick (this is aparent when I set the time to wait to 100 and it never fires off the sub)

I've tried using java, I've tried using the system timer - this is my last hope - please help!

Here's my Code
-----------------

Private strConn As String = ConfigurationSettings.AppSettings("conString")

Private Sub btnAgree_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAgree.Click
Dim oCallback As New TimerCallback(AddressOf OnTick)
Dim lPeriod As Long = 6000
Try
oTimer = New System.Threading.Timer(oCallback, Nothing, 0, lPeriod)
Catch ex As Exception
Response.Write("It Didn't Work")
End Try

pnl4.Enabled = True
pnl4.Visible = True
pnl9.Enabled = False
pnl9.Visible = False


Private Sub OnTick(ByVal state As Object)
pnl4.Visible = False
pnl9.Enabled = True
pnl9.Visible = True

End Sub
 
Try
oTimer = New System.Threading.Timer(oCallback, Nothing, 0,lPeriod)

Catch ex As Exception
Response.Write("It Didn't Work")
End Try

In VB.NET

First define oTimer outside the Try block since its scoped, second lPeriod
is in the wrong position, it should be (oCallback,Nothing,lPeriod,0) if
your intention is to delay the client for 6 sec before moving on.

Hope this helps,
MP
 
Back
Top