Home All Groups Group Topic Archive Search About

My Threading Timer Doesn't Fire

Author
28 Mar 2005 7:43 PM
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

--------------------------------
From: Daniel Maycock

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>yLS52e99KUOB9Bs3Gg9GFA==</Id>

Author
28 Mar 2005 8:21 PM
Scott Simons
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.
Are all your drivers up to date? click for free checkup

Author
28 Mar 2005 8:38 PM
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().

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> 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
>
> --------------------------------
> From: Daniel Maycock
> -----------------------
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>yLS52e99KUOB9Bs3Gg9GFA==</Id>
>
Author
28 Mar 2005 8:51 PM
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

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


Show quoteHide quote
"Daniel Maycock via .NET 247" <anonym***@dotnet247.com> wrote in message
news:%23pg3l58MFHA.3380@TK2MSFTNGP15.phx.gbl...
>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
>
> --------------------------------
> From: Daniel Maycock
>
> -----------------------
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
>
> <Id>yLS52e99KUOB9Bs3Gg9GFA==</Id>

Bookmark and Share