Display icon before end of method

I want to show an icon to let people know they have to wait.
In the beginning of my method i place:
icon.Picture=WaitIcon
and at the end i place a
icon.Picture=DoneIcon

but the first icon is never displayed. The method takes about 10-30 sec to complete.
In desktop i can do a icon.refresh to force an update, but how do i handle this in web.

You’ll need to use a thread to run your code so that the UI can update. Set the icon then start the thread. Use a timer to check for the completion of the thread (use a status variable that you update when your method completes) and then set the second icon.

I can’t seem to implement a thread, it gives an error:
Thread1.Name Layout (property name)
Parameters are not compatible with this function Name

[quote=66795:@Ralf van de Ven]I can’t seem to implement a thread, it gives an error:
Thread1.Name Layout (property name)
Parameters are not compatible with this function Name[/quote]
You must be using a WebDialog or WebContainer. See <https://xojo.com/issue/18766>.

Create the thread as a property. Be sure to initialize the thread with New. Of course, you’ll have to use AddHandler to set the method for the thread to run.