❔ ✅ Best practice for tracking progress for long running method
I am creating a Blazor Server application. I have a method that is compiling some data from a few servers. I'd like to show some sort of progress bar to show the user approximately how much is left. Currently the method just returns a List of all of the objects that was compiled during the process. This is being done in a service class, so I wouldn't have access to the UI elements from the method.
So is there a way to send progress information back to the caller periodically?
I could refactor the method to do 1 server at a time, that way I'll know, for example, that it's 3 of 8 completed, etc. And I could break it down even further to split apart each section of processing to get even more granular. But that seems like it could be more work than it's worth for just a UI nicety. Is there some super neat way of doing this better?
2 Replies