My personal recommendation is to move to HttpClient
away from WebClient
. Then add the Polly library with the retry policy you want. Then your code can focus on just starting the download and waiting for it to complete (or to fail because the retry policy gives up). Focus on your code and let the libraries handle what they are good at.
Also because HttpClient
is async only you don't have to block your UI. You start the download in the background, optionally disabling some UI features, and then wait for it to complete. When it is done then you update your UI again. There are many articles on how to use async with winforms so here is just one article to show you how to do it.
Finally be aware that you should not bother retrying in all cases. There are some errors that will likely never resolve so blindly trying again is not the best solution. This is something that Polly does automatically and is yet another reason you should rely on a third party library for this common functionality.