Deal with threading and download errors #2374
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problems
As of #2351, I'm getting these errors when trying to install a mod on Windows:
Of course this works fine on Linux. Three cheers for "write once run anywhere."
If a downloaded file doesn't pass validation (invalid ZIP, wrong file size or hashes), a few problems happen:
Causes
WinForms on Windows only allows its GUI controls to be accessed from certain threads; other threads have to call
Control.Invoke
to pass code to be run on the appropriate thread. I assume this has to do with it being a wrapper around code from the 1990s, because if you were designing a GUI framework from scratch, you'd probably design it to not care about this sort of thing.That's why
Util.Invoke
is sprinkled throughout the GUI code. The above exception happened on this line:CKAN/GUI/MainWait.cs
Line 27 in a6619fe
... which was being called from a background thread without
Invoke
.Changes
Now
Util.Invoke
calls are added to all affected functions inMainWait.cs
. The status bar progress bar is in a separate block because I found instances during investigation where putting it in the sameInvoke
as the regular progress bar wasn't good enough.InvalidModuleFileKraken
is now caught and displayed to the user inNetAsyncModulesDownloader.ModuleDownloadsComplete
, which allows the loop to finish caching all the downloaded mods.The mod name and version are added to the text for
InvalidModuleFileKraken
.