As far as I know, that could work, can you share an example project to see what’s going on?
I prefer to expose computed properties, instead of making controls public (even in desktop apps). So when you update a computed property, it will update the control.
in fact i made more tests, and use session to store my class instance
it’s a urlConnection
it’s when the content received is triggered that i want to display some text on page.
i made a small project, that crashes when the content received wants to send text to page
Sub ContentReceived(URL As String, HTTPStatus As Integer, content As String) Handles ContentReceived
'Session.myClass.hisString = content
hisString = content
End Sub
give this class the page object in Page Open at new wClass(self)
it means change the construtor
and memory the page object for later user in a property.
seems you can not access the page direct by name in ContentReceived.
The strategy that I use for server-side processes like urlConnection is to create an instance of urlConnection in the Session class, and create its Events as Methods in the Session class (using AddHandler).
However, I never allow urlConnection to touch the UI. Instead, for example, my handler method for contentReceived would write received data into a pre-defined text property of the Session class. (I do this because urlConnection is asynchronous, and we never know when the content will be received.
I then have a WebTimer object that is in the WebPage class, and I set that timer running in continuous mode (1s interval, perhaps) when urlConnection is first called. The timer’s Action event looks for the text property in Session, and when that property is no longer blank, the timer can be turned off and the text can be copied from Session to a label or textArea on the webpage.
Because the timer is within the webpage class, its webpage (and therefore its textArea) are always in scope whenever the page is on display. urlConnection can do its thing, and the timer can do its thing - the two never meet. Keeping the UI separate from background processes like urConnection always seems to work well.