@@ -172,16 +172,20 @@ private async void ModSave_OnClick(object sender, RoutedEventArgs e) {
172172 var progressWindow = new ProgressWindow ( "Applying mods. Please wait..." , true ) ;
173173
174174 progressWindow . Show ( this ) ;
175+
176+ await Task . Yield ( ) ;
175177
176- try {
177- await Program . RunGeneration ( Program . ConvertNewToOldModList ( viewModel . ModList . ToList ( ) ) ) ;
178- } catch ( Exception ex ) {
179- Log . Error ( ex , "Could not generate MLO!" ) ;
180-
181- _ = await MessageBoxWindow . Show ( this , "Error" , "Mods could not be applied. Please make sure that the game directory has write access." +
182- "\n \n Please check\" srmm_errors.txt\" for more info." ) ;
183- }
178+ await Task . Run ( async ( ) => {
179+ try {
180+ await Program . RunGeneration ( Program . ConvertNewToOldModList ( viewModel . ModList . ToList ( ) ) ) ;
181+ } catch ( Exception ex ) {
182+ Log . Error ( ex , "Could not generate MLO!" ) ;
184183
184+ _ = await MessageBoxWindow . Show ( this , "Error" , "Mods could not be applied. Please make sure that the game directory has write access." +
185+ "\n \n Please check\" srmm_errors.txt\" for more info." ) ;
186+ }
187+ } ) ;
188+
185189 progressWindow . Close ( ) ;
186190 } else {
187191 _ = await MessageBoxWindow . Show ( this , "Error" , "Mod list is empty and was not saved." ) ;
@@ -260,18 +264,29 @@ private async void ModInstall_OnClick(object sender, RoutedEventArgs e) {
260264
261265 if ( files . Count == 0 )
262266 return ;
267+
268+ var progressWindow = new ProgressWindow ( "Installing mod(s). Please wait..." , true ) ;
269+
270+ _ = progressWindow . ShowDialog ( this ) ;
263271
264- foreach ( var file in files ) {
265- if ( ! File . Exists ( file . TryGetLocalPath ( ) ) )
266- return ;
272+ await Task . Yield ( ) ;
267273
268- if ( ! await Utils . TryInstallModZipAsync ( file . TryGetLocalPath ( ) ) )
269- continue ;
274+ await Task . Run ( async ( ) => {
275+ foreach ( var file in files ) {
276+ var localPath = file . TryGetLocalPath ( ) ;
277+
278+ if ( ! File . Exists ( localPath ) )
279+ return ;
270280
271- RefreshModList ( ) ;
272- }
281+ await Utils . TryInstallModZipAsync ( localPath ) ;
282+ }
283+
284+ await Program . InstallAllModDependenciesAsync ( ) ;
285+ } ) ;
286+
287+ RefreshModList ( ) ;
273288
274- await Program . InstallAllModDependenciesAsync ( ) ;
289+ progressWindow . Close ( ) ;
275290 } catch ( Exception ex ) {
276291 Log . Fatal ( ex , "ModInstalled failed!" ) ;
277292
0 commit comments