My Threading Timer Doesn't Fire

  • Thread starter Daniel Maycock via .NET 247
  • 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
 
G

Guest

If the timer even fires, there is no http context. The client has
disconnected by then. You will need to do this kind of stuff in javascript on
the client.
 
B

Brock Allen

When using timers you must maintain a reference to the timer, otherwise it
will get GC'd (and then it won't fire). Also, as the other poster mentioned,
this will not have the HttpContext available since it is firing independant
of any request into the server.

You should probabaly use javascript like window.setInterval().
 
S

Steve C. Orr [MVP, MCSD]

This is not a windows forms application.
You must understand that normally a page exists on the server for only a
fraction of a second while it generates the HTML. Therefore server side
timers are darn near worthless.

You'll need to use some client side script for the timer.
Here's an example that uses the javascript setTimeout function.
http://www.crowes.f9.co.uk/Javascript/timer.htm
 

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,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top