timer function

T

TJS

looking for example of timer function

something that will help me get to track user's elapsed time since last
refresh.

tried this but not working with session values correctly in my class

================================================================
Function NewText() As String

Dim vString As String=" "
Dim dtm As DateTime
dtm = DateTime.Now()

If context.session("ScreenTimer") is nothing Then
context.session("ScreenTimer") = Hour(dtm) * 60 + Minute(dtm)
else
context.session("TimeElapsed") = Hour(dtm) * 60 + Minute(dtm) -
cDBL(context.session("ScreenTimer"))
end if

If context.session("TimeElapsed") > 1 Then
vString= "new text here"
context.session("ScreenTimer") = Hour(dtm) * 60 + Minute(dtm)
End If
return vString
End Function
 
P

Philipp Sumi

Hi,

This look pretty complicated :)
Why don't you just store the DateTime directly in to Session?
Code is C#, but I think you get the idea...


store in session
****************

//store initial value:
Context.Session.Add("LastAccess", DateTime.Now);


get elapsed time
****************

//get time passed:
DateTime lastAccess = (DateTime)Session["LastAccess"];

//get the elapsed time
TimeSpan difference = DateTime.Now.Subtract(lastAccess);


hth, Philipp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top