|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
My Threading Timer Doesn't FireI'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> 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. 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> > 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 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>
Other interesting topics
Huge HTML output perfomance
New controls in ASP.NET 2.0 input type="file" grabs ENTIRE file path in IE? Tabs in ASP.Net How to install ISAPI filter for Url Rewriting? Layering Images in ASP.Net 1.1 javascript debugging Dynamic Session State Mode inside of Web.Config paging problem Disable Cookieless Sessions on Single Page? |
|||||||||||||||||||||||