If your server function launches the background task and waits for it to end, then you are back at the starting point.
You need to not wait, and instead use a timer to check for the result.
There are many posts that describe how to do it. Here is the first one I found after a quick search: Trigger Timer on function call - #7 by stefano.menci
Let me know if it helps.