Here is a link where someone asked a similar question and I pointed them to a clone link with some example code of background tasks working:
Here is another link where I just showed off an easy formatting style to keep track of what is what:
Finally, here is a link to when I discovered background tasks due to someone asking about them, with some of the sharper points of the docs smoothed out for a newcomer to the concept:
This should solve many issues someone might have, if the issue really is background task-related.
Edit: You may also run into a problem ( as detailed in the last link ) where you are trying to return a media object directly to the client from a background task, AFAIK that is still not something you are able to do, and something there are have been many discussions about already, with workarounds, etc.