Issue: 11.4 (July/August 2013)
Author: Paul Lefebvre
Author Bio: Paul Lefebvre is the Xojo Developer Evangelist. He has developed software professionally for almost 20 years and has been using Xojo and prior versions since 2001.
Article Description: No description available.
Article Length (in bytes): 6,036
Starting Page Number: 77
Article Number: 11411
Related Web Link(s):
Excerpt of article text...
This month, I jump around a bit with some random topics based on questions I've seen on the forum since Xojo was released.
Accessing Sessions from Threads
As users connect to your web application, a new session is created. In your app, you use the
Sessionobject to store and track session-specific information. As you might expect, every web page that appears is tied to a Session.
But there are some things that are not tied to a Session and one of these is Threads. When you create and start a Thread, the Thread has no direct reference to the Session that created it. This means it cannot access the Session object and it cannot access web pages. This may not be a problem if your thread is autonomous and is given all the information it needs.
But if you want the thread to access a Session or talk to a web page, you have to use a slightly different design.
One technique is to use the
WebSessionContextclass, but this is only needed in a very special case: when you need to access web pages using their implicit names from within the thread. And, unfortunately,
WebSessionContexthas not been completely reliable in the last couple of releases, so I recommend avoiding it.
...End of Excerpt. Please purchase the magazine to read the full article.