I am running xojo 64bit linux unbuntu (latest) web version of xojo.
I have a form with a shell, I can run a command to the shell and get the answer back, however if I update a textarea with the result it never updates (leaves what was initially there)
I have tried to webpage.updatebrowser textarea.updatebrowser. setfocus, write it more than once. Even changed the code so that a timer picked up the interactive shell answer and tried to update.
The data comes back from the shell ok, it just never updates the screen, I have tried browser and server based timers.
Is this a bug?
It works ok locally on windows. Just not when its running on liunx
She’ll runs on the main thread, not in the thread where your session code is running. You’re going to have to subclass Shell, add a string property to it that gets set to Session.Identifier when you instantiate it, run the shell asynchronously and then in the Completed event, create a WebSessionContext from the stored identifier. That should get you back on track.
What I don’t understand is why aren’t people who do this getting some kind of missing session context or nil object exception?
Yeah I don’t know. Accessing a session object from a non session thread definitely should raise the SessionNotFound exception. But so many users just put Return True
in the App.UnhandledException
event handler any more, I just don’t go there.
Try that trick but use a WebTimer instead.
This works ok as a web version in Windows, are you saying that the same code is not cross compatible with Linux?
Greg is there an example of this as I have not used these features and it looks like it may involve some reading and trial and error. I just want to update a text box in linux web version from a timer or directly or any other method.
It is a web timer?
If you look at the passage I quoted, you said you used a Timer to pick up the results. I said “use a WebTimer instead”. The WebTimer is session aware when you instantiate it within a session or place one on a webPage or WebContainer. If you use it, it will send to the right session.
Otherwise, you will need to subclass Shell to do the same thing. It’s not difficult though:
- Subclass the Shell class.
- Add a private property called
SessionIdentifier as String
. - Add a Constructor method and add the following code:
Self.SessionIdentifier = Session.Identifier
- Add the Completed event.
- Right-click the Completed event and select “Add Event Handler”.
- In the Completed event you will add the following code:
Dim ctx as New WebSessionContext(Self.SessionIdentifier)
#if DebugBuild
If ctx = Nil then
Break // you will hit this breakpoint if the session no longer exists when debugging
End If
#EndIf
RaiseEvent Completed
It’s a fluke that it’s working locally on Windows.
Sorry, I was using a webtimer.
In the shell, when I right click Completed there is no menu option that says Add Event Handler?
I’ll have to look tomorrow. It’s past 11p here
No problem (4:19am) here
Here’s what I mean though…
The WebShell class that’s in there, When created at runtime, it will store the session identifier and then make that session current when the DataAvailable and Completed events fire.
FWIW, this technique can also be used for any of the “main thread items” like Serial and any of the Sockets. It’s what WebTimer does under the hood in Web 2 when the Location property is set to Server.