473,385 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

My Threading Timer Doesn't Fire

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>
Nov 19 '05 #1
3 1754
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.
Nov 19 '05 #2
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
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>


Nov 19 '05 #3
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
"Daniel Maycock via .NET 247" <an*******@dotnet247.com> wrote in message
news:%2****************@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>

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ELO | last post by:
Hi all Every week, I need to get two files on a remote server. I have developped a C# Windows Service with two System.Threading.Timer to do this task For the first one, the delay (TimeSpan...
1
by: Tom | last post by:
I've googled, and read, and stripped out code, and rewritten code, and still can't get a System.Threading.Timer to work. (I hereby publicly admit that I'm a failure here...) Could someone please...
6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
5
by: Deiussum | last post by:
I'm running into an issue where I have a timer that appears to be timing out immediately, when it shouldn't be timing out for about int.MaxValue milliseconds. I have written a small app that...
1
by: Paul Tomlinson | last post by:
Question about a System.Threading.Timer object and the "state" object you pass to it... Timer stateTimer = new Timer( = new TimerCallback( OnTimer ), o, 1000, 1000); I have an array of timer...
2
by: steve | last post by:
Since System.Threading.Timer uses the threadpool to do its stuff what happens when (a) You try to create a timer and the thread pool is *exhausted* (b) The timer is due to fire AND all threads...
8
by: Luc | last post by:
Hi, I am writing software to automate some testing. I have one main form to set up the tests, and once this is complete, I open 4 identical forms to monitor each different device that I am...
7
by: melton9 | last post by:
I have a web service that I believe needs to implement threading. I have a timer setup to fire 3 requests and have them do some calculations and send the info to the mainform. I also need the...
8
by: KnighT | last post by:
I have a .net service that runs a System.Threading.Timer. The delegate points to the function that the service should execute when the timer elapses. Problem: The timer is not ticking. I have...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.