473,545 Members | 721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Timer problem

Hi

i have function like above

Public Sub halytystutkinta ()
Dim ds As New DataSet
ds = dl2.HaeHalytys( )
Dim onkohal As Int16
onkohal = ds.Tables(0).Ro ws(0).Item("onk ohalytys")
halid = ds.Tables(0).Ro ws(0).Item("hal id")
If onkohal = 1 Then
Beep()
Label2.Text = "Halytys, halytys"
Image1.DataBind ()
Beep()
End If
End Sub

and i try to use that function with timer like this

Private Sub OnTimer(ByVal source As Object, ByVal e As System.Timers.E lapsedEventArgs )
otakuva()
End Sub

Private Sub KaynnistaPalvel u()
AddHandler aTimer.Elapsed, AddressOf OnTimera

aTimer.Interval = 20000
aTimer.Enabled = True
end sub

but that doesnt not work
but if i call if call function halytystutkinta
like above it works

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
halytystutkinta ()
End Sub

it is asp.net application

Nov 18 '05 #1
6 2038
see inline

"Antti Laakso" <an**********@h otmail.com> wrote in message news:FC******** *************** ***********@mic rosoft.com...
Hi

i have function like above

Public Sub halytystutkinta ()
Dim ds As New DataSet
ds = dl2.HaeHalytys( )
Dim onkohal As Int16
onkohal = ds.Tables(0).Ro ws(0).Item("onk ohalytys")
halid = ds.Tables(0).Ro ws(0).Item("hal id")
If onkohal = 1 Then
Beep()
Note: Beep (IF it works) would be a server-side function
Label2.Text = "Halytys, halytys"
Image1.DataBind ()
Beep()
End If
End Sub

and i try to use that function with timer like this

Private Sub OnTimer(ByVal source As Object, ByVal e As System.Timers.E lapsedEventArgs )
otakuva()
Where is this function "otakuva" declared? Shouldn't it be "halytystutkint a" ?
End Sub

Private Sub KaynnistaPalvel u()
AddHandler aTimer.Elapsed, AddressOf OnTimera

Is "OnTimerA" a typo in the post? I think you mean "OnTimer".
aTimer.Interval = 20000
aTimer.Enabled = True
end sub

but that doesnt not work
but if i call if call function halytystutkinta
like above it works

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
halytystutkinta ()
End Sub

it is asp.net application


Do you define the timer in an aspx page? That will NOT work as the lifetime
of that page (class) is one request. The next request will use a fresh class
where the timer will be reset. So the timer never fires!
It IS possible to use a timer, but (for asp.net) only in Global.asax.

What are you trying to do with this timer? Why are you using it?

Hans Kesting
Nov 18 '05 #2


"Hans Kesting" wrote:
see inline

"Antti Laakso" <an**********@h otmail.com> wrote in message news:FC******** *************** ***********@mic rosoft.com...
Hi

i have function like above

Public Sub halytystutkinta ()
Dim ds As New DataSet
ds = dl2.HaeHalytys( )
Dim onkohal As Int16
onkohal = ds.Tables(0).Ro ws(0).Item("onk ohalytys")
halid = ds.Tables(0).Ro ws(0).Item("hal id")
If onkohal = 1 Then
Beep()
Note: Beep (IF it works) would be a server-side function
Label2.Text = "Halytys, halytys"
Image1.DataBind ()
Beep()
End If
End Sub

and i try to use that function with timer like this

Private Sub OnTimer(ByVal source As Object, ByVal e As System.Timers.E lapsedEventArgs )
otakuva()


Where is this function "otakuva" declared? Shouldn't it be "halytystutkint a" ?
it's a different function

End Sub

Private Sub KaynnistaPalvel u()
AddHandler aTimer.Elapsed, AddressOf OnTimera


Is "OnTimerA" a typo in the post? I think you mean "OnTimer".

there is two timers
aTimer.Interval = 20000
aTimer.Enabled = True
end sub

but that doesnt not work
but if i call if call function halytystutkinta
like above it works

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
halytystutkinta ()
End Sub

it is asp.net application

Do you define the timer in an aspx page? That will NOT work as the lifetime
of that page (class) is one request. The next request will use a fresh class
where the timer will be reset. So the timer never fires!
It IS possible to use a timer, but (for asp.net) only in Global.asax.

What are you trying to do with this timer? Why are you using it?


yes in aspx page. when timer fires it should call webservice which accesses a database and returns a dataset which contains information about alarms. i'll need to get that data from webservice about every 10seconds
Hans Kesting

Nov 18 '05 #3
> >
Do you define the timer in an aspx page? That will NOT work as the lifetime
of that page (class) is one request. The next request will use a fresh class
where the timer will be reset. So the timer never fires!
It IS possible to use a timer, but (for asp.net) only in Global.asax.

What are you trying to do with this timer? Why are you using it?


yes in aspx page. when timer fires it should call webservice which accesses a database and returns a dataset which contains

information about alarms. i'll need to get that data from webservice about every 10seconds


Then that's the problem. The aspx page is finished in milliseconds so the timer gets destroyed long
before it can fire.

Possibly you can change the timer to client-side, using a <meta http-equiv=refresh content=10> tag in the html to
refresh the page every 10 seconds. In the page get the data immediately to build html to
send back to the browser.

Hans Kesting
Nov 18 '05 #4

i once wrote a e-mail system that i wanted to be a-synchronous

i.o.w. i did not want the aspx page to wait untill the e-mail was generated
and send ( inmediate response back to the user )

what i did was the folowing

i added a standard module , declared a public class with properties and a
method sendmail

my aspx page received the parameters from the web , i passed these
parameters to the class module ( the parameters were e-mail adress to send
to , the message etc etc etc )

at last i called the method sendmail wich started a timer with delay of 500
miliseconds , when the timer triggered it would generate and send the e-mail

this did the trick for me ,,,,

what i wanted to say with this story is that it sure is possible to use a
timer in ASP.NET pages however they should be called from global code

M. Posseth [MCP]


"Hans Kesting" <ne***********@ spamgourmet.com > wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .

Do you define the timer in an aspx page? That will NOT work as the lifetime of that page (class) is one request. The next request will use a fresh class where the timer will be reset. So the timer never fires!
It IS possible to use a timer, but (for asp.net) only in Global.asax.

What are you trying to do with this timer? Why are you using it?
yes in aspx page. when timer fires it should call webservice which accesses a database and returns a dataset which contains information about alarms. i'll need to get that data from webservice about every 10seconds


Then that's the problem. The aspx page is finished in milliseconds so the

timer gets destroyed long before it can fire.

Possibly you can change the timer to client-side, using a <meta http-equiv=refresh content=10> tag in the html to refresh the page every 10 seconds. In the page get the data immediately to build html to send back to the browser.

Hans Kesting

Nov 18 '05 #5
Thank's for help!

"Hans Kesting" wrote:

Do you define the timer in an aspx page? That will NOT work as the lifetime
of that page (class) is one request. The next request will use a fresh class
where the timer will be reset. So the timer never fires!
It IS possible to use a timer, but (for asp.net) only in Global.asax.

What are you trying to do with this timer? Why are you using it?


yes in aspx page. when timer fires it should call webservice which accesses a database and returns a dataset which contains

information about alarms. i'll need to get that data from webservice about every 10seconds


Then that's the problem. The aspx page is finished in milliseconds so the timer gets destroyed long
before it can fire.

Possibly you can change the timer to client-side, using a <meta http-equiv=refresh content=10> tag in the html to
refresh the page every 10 seconds. In the page get the data immediately to build html to
send back to the browser.

Hans Kesting

Nov 18 '05 #6
Thank's for help!

"M. Posseth" wrote:

i once wrote a e-mail system that i wanted to be a-synchronous

i.o.w. i did not want the aspx page to wait untill the e-mail was generated
and send ( inmediate response back to the user )

what i did was the folowing

i added a standard module , declared a public class with properties and a
method sendmail

my aspx page received the parameters from the web , i passed these
parameters to the class module ( the parameters were e-mail adress to send
to , the message etc etc etc )

at last i called the method sendmail wich started a timer with delay of 500
miliseconds , when the timer triggered it would generate and send the e-mail

this did the trick for me ,,,,

what i wanted to say with this story is that it sure is possible to use a
timer in ASP.NET pages however they should be called from global code

M. Posseth [MCP]


"Hans Kesting" <ne***********@ spamgourmet.com > wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
>
> Do you define the timer in an aspx page? That will NOT work as the lifetime > of that page (class) is one request. The next request will use a fresh class > where the timer will be reset. So the timer never fires!
> It IS possible to use a timer, but (for asp.net) only in Global.asax.
>
> What are you trying to do with this timer? Why are you using it?

yes in aspx page. when timer fires it should call webservice which accesses a database and returns a dataset which contains
information about alarms. i'll need to get that data from webservice about

every 10seconds >


Then that's the problem. The aspx page is finished in milliseconds so the

timer gets destroyed long
before it can fire.

Possibly you can change the timer to client-side, using a <meta

http-equiv=refresh content=10> tag in the html to
refresh the page every 10 seconds. In the page get the data immediately to

build html to
send back to the browser.

Hans Kesting


Nov 18 '05 #7

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

Similar topics

13
7455
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on it, a frontend and a backend. Case 1: If vba code on the frontend updates many rows (360,000) on the backend, a form's timer event (from the...
11
2548
by: Steve Jorgensen | last post by:
I've recently been playing with some UI ideas that require the user of a timer to drive animation. The problem I'm having is that Access routinely stops firing timer events for long periods of time. For example, the user types a character in another window, and the timer stops. The user types another key, and the timer starts again, runs...
9
7252
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null; Let's declare a constant Int32 m_TimePeriod = 10000;
4
11093
by: Liverpool fan | last post by:
I have a windows application written using VB .NET that encompasses a countdown timer modal dialog. The timer is a System.Timers.Timer with an interval of 1 second. AutoReset is not set so accepts the default of True. The Elapsed event handler updates the dialog box with how long before it will close, acting as a timer itself. The dialog has a...
4
1680
by: Daniel | last post by:
Hey guys Here is what i want to do. I have made a multiplayer game that needs to when more than one player is ready start a countdown that the clients can see, so players can still join in this time frame and then after the time elapses the game starts. I am trying to do it lie this, my server controls all handling of the game logic,...
4
4622
by: grayaii | last post by:
Hi, I have a simple form that handles all its paint functionality like so: this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); And the entry point to this program is like so: static void Main() {
8
6841
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 never used this timer. I used the documentation from Microsoft as a guide, but I cannot get this timer to work. Protected Overrides Sub...
8
2640
by: =?Utf-8?B?RGF2ZSBCb29rZXI=?= | last post by:
I have a Timer that I set to go off once a day, but it frequently fails! In order to debug I would like to be able to check, at any moment, whether the Timer is enabled and when it will next Elapse. Is there any way -- whether in my code, or in the O/S -- to determine when a Timer is scheduled to Elapse?
16
3232
by: Peter Oliphant | last post by:
Note that although this involves SAPI, it is more a question about Timers and event handlers. I wrote a Speech Recognize handler (SAPI), and put some code in it to enable a Timer. It would not do it. If I bring this same code outside this event handler, it works just fine. Is this normal?
2
4521
by: Johnny Jörgensen | last post by:
I've got a process I want to run in a thread separate from my main application thread, so I've used a backgroundworker component, and in frmMain.Load I invoke the code using Backgroundworker1.RunWorkerAsync(). So far so good, this works fine. But when the process is done, I want to wait 30 minutes and then run the process again. So I added a...
0
7465
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7398
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7805
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7752
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1878
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.