private async Task AddMods(string[] files)
        {
            await TaskManager.WaitForTasks();

            var busyModel = new BusyDialogViewModel()
            {
                Text = "Installing mod"
            };

            BusyDialog.DialogContent = busyModel;
            BusyDialog.IsOpen        = true;


            Mod mod = null;

            try
            {
                mod = await ModManager.Instance.AddMod(files);
            }
            catch (Exception ex)
            {
                Errors.Handle("Failed to install mod", ex);
            }
            BusyDialog.IsOpen = false;
            TaskManager.AddBackgroundTask("Deleting temporary files", TempFolder.ClearAsync());
            if (mod != null && string.IsNullOrEmpty(mod.Name))
            {
                await MaterialDesignThemes.Wpf.DialogHost.Show(mod);
            }
        }
Example #2
0
        public static async Task WaitForTasks()
        {
            if (tasks.Count == 0)
            {
                return;
            }
            var busyDialogViewModel = new BusyDialogViewModel();

            Settings.mainWindow.BusyDialog.DialogContent = busyDialogViewModel;
            Settings.mainWindow.BusyDialog.IsOpen        = true;
            while (tasks.Count > 0)
            {
                var namedTask = tasks[0];
                if (!namedTask.task.IsCompleted)
                {
                    busyDialogViewModel.Text = namedTask.description;
                    await namedTask.task;
                }
                tasks.RemoveAt(0);
            }
            Settings.mainWindow.BusyDialog.IsOpen = false;
        }