I have a very long processing Method on my Webpage and would like to display a Spinner wheel while processing the data.
In the button that processes the Data I have the following code:
//Show the GIF picture that spins
ExecuteJavaScript(" Xojo.get('" + me.ControlID + "_loader').style.display = 'inherit'; ")
//Execute the very long code here
...
//Hide the GIF picture that spins
Xojo.get('" + me.ControlID + "_loader').style.display = 'none';")
The spinner displays then disappears very quickly but only after the long code was executed. It doesn’t display before the whole Data processing.
So it seems that the ExecuteJavascript function is only executed when the application is idle.
I have tried executing the javascript within a thread that was called before the long code, to no effect.
[quote=118692:@JrmieLeroy]I have a very long processing Method on my Webpage and would like to display a Spinner wheel while processing the data.
In the button that processes the Data I have the following code:
//Show the GIF picture that spins
ExecuteJavaScript(" Xojo.get('" + me.ControlID + "_loader').style.display = 'inherit'; ")
//Execute the very long code here
...
//Hide the GIF picture that spins
Xojo.get('" + me.ControlID + "_loader').style.display = 'none';")
The spinner displays then disappears very quickly but only after the long code was executed. It doesn’t display before the whole Data processing.
So it seems that the ExecuteJavascript function is only executed when the application is idle.
I have tried executing the javascript within a thread that was called before the long code, to no effect.
Is there any solution for this ?[/quote]
I don’t have your image, but I tried with this (ProgressWheel1 is invisible in the inspector):
Sub Action()
ProgressWheel1.Visible = true
System.debuglog "show PW"
dim deja as integer = ticks
while ticks-deja<300
wend
ProgressWheel1.visible = false
System.DebugLog "hide PW"
End Sub
Although the log shows the ProgressWheel becoming visible at 15:01:23 and back to invisible at 15:01:28, it actually never shows up. I suspect the page is not updated when the wheel is rendered visible. The same maybe happening with your code, the page gets updated after the long operation.
You may want to use system.debuglog in your program as well as console.log in JavaScript to track the order of events, but it is quite possible that your JavaScript does execute, but it does not show.
Nothing is sent to the browser until the current event completes. You need to separate your code into to 2 distinct events: one to show the progresswheel and one to run the long chunk of code and then hide the progresswheel. You can use a webtimer to do this. In the current event, show the progresswheel and start a short period timer (fires immediately). In the timer action event, put the rest of your code.