I guess that’s when it’s busy with round trips, each checking its own background task. With a stack you would have only one round trip per second. It would be slightly slower, but the app would not hang.
But for simple cases where you have the freedom to abuse the resources, the component with its own timer is the most elegant solution.
1 Like
Here is my use case,
each row contains details about a movie, columns are coming from 3 different websites, from an uplink server function scraping and parsing the sites with beautiful soup.
once the row has been populated with complete data set, no more server calls would be raised from it ever. component will call the server function only if it has incomplete data.
if one thread gets killed, no worries, next one will populate the data.
concurrent visitors might raise multiple calls for the same row, but my thread function takes care of that.
It’s just a weekend project and exploring anvil. So, I am not concerned about hackers.
1 Like
That’s nice!
But, for my case i don’t need to call the background task every time that component is on screen.
Only the first time ever it has been on any screen to populate it’s missing data.
I could have done it at the time of adding the row to database making sure it has complete data.
I thought why not populate it only on demand. Background tasks seemed too resource heavy for my use case. I can run a thousand threads but not nearly enough processes.