WebSessions and Xojo.Core.Timer.CallLater

In WebApps, if I use Xojo.Core.Timer.CallLater, should I expect to be able to access the WebSession?

When I get inside the method that I called using CallLater, my session is nil.

I should say, I’m calling CallLater in a Method on a Page, not from the Session.

Timers and socket events do not have access to the session. But you can use http://documentation.xojo.com/index.php/WebSessionContext to bring it there.

Thank you Michel. It makes sense.

I’m able to get around the problem by dragging a timer to my page and having the timer call my method.

I’m doing this so when the user clicks, it shows a spinner, hides my detail container, and then starts the timer. When the Timer fires, my method runs and then hides the spinner and shows the detail container. Otherwise the round trip could be too long.

I wish I could call something like “updatePageUI” rather than having to use a timer to show the spinner when processing might take a while.

Hal, show the spinner and start the process in a WebThread when the user clicks run. Then use the webtimer to hide the spinner and show the results when the thread finishes.

Thanks for that Greg… Do WebThreads have access to the session?

Just read they do! Thanks Greg!!!

Lets put it this way… if a WebThread is started from within a session, then yes it does. Otherwise they behave just like regular threads.

I just looked at the Example in Web Controls called “ThreadProgress”. It’s perfect.

Thank you Greg!

Wow. Using WebThreads is so much faster than when I was using updating the UI with a spinner and then using a timer to do the main job.

With the WebThreads, I don’t even see the Please Wait dialog appear! I had to include the sleep code to actually see the Please Wait appear.

Thanks so much!