How to deal with threading

Background tasks cannot interact with the form because they run on the server, not on the client.

The code on the client calls a function on the server, that function starts the background task and returns something to the client, the code on the client changes something on the form and ends. There is no way for the background task to contact the client and send some information.

You could use a timer on the form to call another server function that checks the status of the background task or checks the database modified by the background task.

Or, if the job done by the background task is fast, you could use a timer with 30 seconds instead of a background task. But you can do this only if it’s ok for the delayed job not to run if the user closes the browser before the timer ticks.

1 Like