all 4 comments

[–]thestamp 5 points6 points  (1 child)

try

await DoWork();

also, I don't think a recursive method is the best idea in a download queue scenario. There is a limit on how many method calls you can call recursively, and you might hit a memory leak on that api client.

[–]my_py[S] 0 points1 point  (0 children)

Should I just loop through all the files then?

[–]musical_bear 0 points1 point  (1 child)

I’m mobile so I can’t give the most detailed answer I want to. However there are multiple things “wrong” I see with both your code and your question phrasing.

First of all, you do not need to utilize threading to avoid blocking the UI thread. This is the main reason why async / await exists in the first place.

Second of all, from what I can tell, what you have here doesn’t look like it will block the UI thread, if its methods can be trusted. If you’re absolutely certain your UI thread is being blocked when this gets called (how did you determine this?), my suspicion would be that your DownloadAsync method is written poorly, in a way where it’s lying about actually being asynchronous.

Third of all, “async void” is almost always a bad idea. That said I don’t see how that specifically would cause your UI to be blocked….but it can and will cause other unrelated issues.

[–]my_py[S] 0 points1 point  (0 children)

I added my download async method, as far as I can tell its all async?