Fragjacker / DoW-Mod-Manager

The original repository for the DoW Mod Manager application, which was made for the Dawn of War:tm: series.
MIT License
33 stars 7 forks source link

Error message to git without internet connection. #36

Open Swanky1337 opened 2 years ago

Swanky1337 commented 2 years ago

Mod Manager takes a while to establish its connection to git and times out if no internet connection is available. This alt-tabs you out of Dawn of War, if you're already running the application.

IgorTheLight commented 1 year ago

Mod Manager takes a while to establish its connection to git and times out if no internet connection is available. This alt-tabs you out of Dawn of War, if you're already running the application.

For me, it shows a message after a second - can't reproduce any long delays before showing the message. You could disable "Autoupdate" if your Internet connection is unreliable. If we wouldn't show the message at all - that could confuse people about their problems with autoupdating or downloading a Modlist.

Fragjacker commented 1 year ago

The only way I could imagine this happening if the download would happen in the main UI thread and then, once finished, attempt to regrab Window focus.

I have checked it and indeed the DownloadString function is not running in a seperate thread but the main UI thread. This could potentially explain the issue. @IgorTheLight you may want to take a look at this and wrap this function in a thread 😄 .

IgorTheLight commented 1 year ago

The only way I could imagine this happening if the download would happen in the main UI thread and then, once finished, attempt to regrab Window focus.

I have checked it and indeed the DownloadString function is not running in a seperate thread but the main UI thread. This could potentially explain the issue. @IgorTheLight you may want to take a look at this and wrap this function in a thread 😄 .

Oh, Ok - I will look into that!

IgorTheLight commented 1 year ago

Hm... The whole Autoupdate is in another Thread already - that's why I didn't changed anything before. (MoDManagerForm.cs, from line 198):

if (settings[AUTOUPDATE] == 1) { new Thread(() => { DialogResult result = DownloadHelper.CheckForUpdates(silently: true); if (result == DialogResult.OK && settings[AOT_COMPILATION] == 1) settings[ACTION_STATE] = (int)Action.CreateNativeImage; } ).Start(); } So it's not on the main Thread already, right? xD

IgorTheLight commented 1 year ago

I think, that it's our ThemedMessageBox that causes this problem. Can't confirm that because I can't reproduce the bug itself. I will create new Form in a new Thread and see what will happen xD

IgorTheLight commented 1 year ago

Yep - it is! ShowDialog() mean to be used as a Warning or Error window, so it should take focus. That's why I chose it too! The problem here is that it's not showed fast, so user see no errors and starts the game. Then fetching version number from GitHub fails and an error message appears (using ShowDialog() method). The root of the problem is why it takes so much time to understand that there is o connection? For me it's like 1 second! Can you reproduce this delay?