WebTimer stops working

Why would a WebTimer just stop working. I am setting a boolean session flag when initializing my web dialogs and/or containers to prevent various controls valuechanged and selectionchanged events from firing. The WebTimer’s period is set to 10 and is used to reset the flag to false.

Basically I set the flag at the biginning of an initialization method, set the default values of the various objects and controls then call the WebTimer to reset the flag…

[code]Session.SkipSelectionChangedEvent = true
cb_RearchInst.Value = true

cb_xxxx.value = true
SiteHomePage.EventHandlersOn.Mode = Timer.ModeSingle [/code]

The timer simply resets the flag…

session.SkipSelectionChangedEvent = false me.Mode = Timer.ModeOff

The controls changedvalue events check the flag before running the code. I need the timer because the control events apparently do not fire until after the intialization method finishes running so simply setting the flag back to false at the end of the intialization method does not work…

This works fine 95% of the time, but occasionally the timer simply stops running and will not run again until the webapp is reloaded.

Probably more info is required, but I am hoping that I met get a few suggestions of what might be causing this to happen. I have spent hours trying to track down the cause.

No idea why this happens, if indeed all the webTimer contains is these two lines. Maybe something else on the page is hindering the WebTimer working.

You can try to use a server side Timer instead. Insert a class, make its super Timer, and you will be able to drag it to the page just the same way as a WebTimer. Then add the Action event the very same way.

10 is way too short. If you’re just setting a flag, I suggest using a regular timer object.

I considered the possibility that the timer was too short, but if so why would that prevent the 2 lines of code from running? Won’t the action event run regardless the period length?

@Greg O’Lone what is a “regular timer object”. I created the timer by dragging a webtimer from the Controls Library into my web page and adding the action event. Do you mean to create it in code?

@Michel Bujardet I don’t think I can use a server side Timer as the flag being set in the timer action event is a session parameter. I tried and it throws a nil object exception on the flag. Doesn’t make sense to me to use a server side timer as each session must have it’s own event skipping flag.

The instance of the timer will be part of the page, and as such, part of the session. BUT events in timers, as well as sockets, do not have direct access to the Session object. You need to use WebSessionContext. I replied already to that last week :

BTW I think Greg is telling you the same thing I do. I think by “regular timer object”, he means the same timer as in Desktop, AKA server side.

@Michel Bujardet your other thread was very helpful. Unlike the WebTimer, the server side Timer appears to work consistently, but I don’t understand why.

Should I avoid using WebTimers?

Also, just to clarify in my mind how WebSessionContext works. The documentation shows using the context object like this…

Dim context As New WebSessionContext(App.SessionAtIndex(i)) context.Session.CurrentPage = New ExceptionPage

CurrentPage is a parameter of the Session class so that works. But you cannot use the context object when addressing a paramter in the session. However, this does work…

Dim context As New WebSessionContext(thisSession) session.SkipSelectionChangedEvent = false

So by simply declaring the context object the event method gains access to the session object??

WebTimer is a JavaScript, browser side control. As such, it has limitations, the minimum period being one of them. A server side timer can have a much shorter effective period. Most of the time a WebTimer will be fine, but you must know you have a recourse if it does not.

I pointed you to the other thread precisely because I outline the exact way I use to get the session in the action event :

Mochel, you other thread was great. It never got down to the actual call to a session parameter, however, and I was wondering if it was normal that simply instantiating the WebSessionContext object was all you needed to gain access to the session parameters. I was surprised that this works…

Dim context As New WebSessionContext(thisSession) session.SkipSelectionChangedEvent = false

In the above example context remains reported as an unused local variable. As long as it works, I’m good. I was just curious about what was going on here exactly.


You missed the most important :

thisSession must be a property of the WebPage set to session in its open event. So indeed initiating the WebSession object is just fine, at the condition that it be created with the current session as reference.

Then you can address session from within that event.

I think I understand what you just said. :wink:

No problem. With your help, my server side Timer is working like a champ. Thanks again.