How to run a Timer on Web App.Open?

We have a web app that needs to send out notification emails, but I’m having problems. I planned to run a timer on the App level which would then run a thread to query the database and send out the emails.

First, I tested sending an email on That works great.

So I added a Timer Class to the project and a Property to the App based on the Class. Then I added this code to the The Timer Class action simply sends me an email on Action.

if AppNotificationsTimer = nil then AppNotificationsTimer = New NotificationsTimer AppNotificationsTimer.Mode = Timer.ModeMultiple AppNotificationsTimer.Period = 5000 AppNotificationsTimer.Enabled = True end if

That caused an SessionNotAvailableExeption: “control cannot be created because no session context” on AppNotificationsTimer = New NotificationsTimer.

So can I run code on the server ? Is there a way to make this work or a better way to accomplish the same?

Are you using a Timer or a WebTimer? WebTimers require a Session.

OHHHH! I was using a WebTimer as I thought I had to since it was a web app. But now it makes sense that the Pages need WebTimers and the App can use a Timer.

I changed it from being a WebTimer to a Timer and it’s working!

Thank you Greg!

Can you please make it more clear , i have an issue also with the webtimer, it suppose to update some textFields every 5 seconds and a progress bar but it seems that it does not even fire. i checked the method that is invoking it and it is functional, i get the response so there is something in the WebTimer that does not work and on the docs site there is a simple sample that does not show sessions and other option that you need to use to make it functional.

Just an update , the app is standalone, maybe that helps.