473,387 Members | 1,574 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,387 software developers and data experts.

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).Rows(0).Item("onkohalytys")
halid = ds.Tables(0).Rows(0).Item("halid")
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.ElapsedEventArgs)
otakuva()
End Sub

Private Sub KaynnistaPalvelu()
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(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
halytystutkinta()
End Sub

it is asp.net application

Nov 18 '05 #1
6 2027
see inline

"Antti Laakso" <an**********@hotmail.com> wrote in message news:FC**********************************@microsof t.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).Rows(0).Item("onkohalytys")
halid = ds.Tables(0).Rows(0).Item("halid")
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.ElapsedEventArgs)
otakuva()
Where is this function "otakuva" declared? Shouldn't it be "halytystutkinta" ?
End Sub

Private Sub KaynnistaPalvelu()
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(ByVal sender As System.Object, ByVal e As System.EventArgs) 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**********@hotmail.com> wrote in message news:FC**********************************@microsof t.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).Rows(0).Item("onkohalytys")
halid = ds.Tables(0).Rows(0).Item("halid")
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.ElapsedEventArgs)
otakuva()


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

End Sub

Private Sub KaynnistaPalvelu()
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(ByVal sender As System.Object, ByVal e As System.EventArgs) 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***************@TK2MSFTNGP10.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***************@TK2MSFTNGP10.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
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...
11
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...
9
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;...
4
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...
4
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...
4
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...
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...
8
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...
16
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.