When I was working on the WithProgress extensions I learned something about Progress<T> that I didn't expect.
My mistake was that I assumed that Progress<T> would complete synchronously when progress was reported. Turned out however that the Progress<T> implementation post progress reports that complete asynchronously which means that you might actually get progress reports out of order due to how they are scheduled by the operating system.
While this behavior is good since it protects the source of the progress reports from being blocked by a slow progress handler it is unfortunate that there is no way to change this behavior without implementing your own IProgress<T> instance.
Hence I implemented a ProgressSimple class that just calls its progress handler rather than schedule it for execution. Since this also could be a problem for the source if the progress handler threw an exception I also created the ProgressSafe class that will ignore any exceptions and that way protects the source from unexpected errors. You can still get the last error out of ProgressSafe if you want to.
Post a Comment