diff --git a/AssetStudio.CLI/Program.cs b/AssetStudio.CLI/Program.cs index 7103be4..57c3b41 100644 --- a/AssetStudio.CLI/Program.cs +++ b/AssetStudio.CLI/Program.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading.Tasks; using AssetStudio.CLI.Properties; using Newtonsoft.Json; using static AssetStudio.CLI.Studio; @@ -155,12 +156,12 @@ namespace AssetStudio.CLI { throw new Exception("Unable to build AssetMap with input_path as a file !!"); } - AssetsHelper.BuildAssetMap(files, o.MapName, game, o.Output.FullName, o.MapType, classTypeFilter, o.NameFilter, o.ContainerFilter); + Task.Run(() => AssetsHelper.BuildAssetMap(files, o.MapName, game, o.Output.FullName, o.MapType, classTypeFilter, o.NameFilter, o.ContainerFilter)).Wait(); } } if (o.MapOp.HasFlag(MapOpType.Both)) { - AssetsHelper.BuildBoth(files, o.MapName, o.Input.FullName, game, o.Output.FullName, o.MapType, classTypeFilter, o.NameFilter, o.ContainerFilter); + Task.Run(() => AssetsHelper.BuildBoth(files, o.MapName, o.Input.FullName, game, o.Output.FullName, o.MapType, classTypeFilter, o.NameFilter, o.ContainerFilter)).Wait(); } if (o.MapOp.Equals(MapOpType.None) || o.MapOp.HasFlag(MapOpType.Load)) { diff --git a/AssetStudio.GUI/MainForm.cs b/AssetStudio.GUI/MainForm.cs index d0d3dd9..8ec825e 100644 --- a/AssetStudio.GUI/MainForm.cs +++ b/AssetStudio.GUI/MainForm.cs @@ -2218,7 +2218,7 @@ namespace AssetStudio.GUI InvokeUpdate(miscToolStripMenuItem, true); } - private async void buildBothToolStripMenuItem_Click(object sender, EventArgs e) + private async Task buildBothToolStripMenuItem_Click(object sender, EventArgs e) { miscToolStripMenuItem.DropDown.Visible = false; InvokeUpdate(miscToolStripMenuItem, false); @@ -2406,7 +2406,7 @@ namespace AssetStudio.GUI Console.Clear(); } - private async void buildAssetMapToolStripMenuItem_Click(object sender, EventArgs e) + private async Task buildAssetMapToolStripMenuItem_Click(object sender, EventArgs e) { miscToolStripMenuItem.DropDown.Visible = false; InvokeUpdate(miscToolStripMenuItem, false); diff --git a/AssetStudio/AssetsHelper.cs b/AssetStudio/AssetsHelper.cs index c87daf1..a9893ed 100644 --- a/AssetStudio/AssetsHelper.cs +++ b/AssetStudio/AssetsHelper.cs @@ -313,7 +313,7 @@ namespace AssetStudio } } - public static async void BuildAssetMap(string[] files, string mapName, Game game, string savePath, ExportListType exportListType, ClassIDType[] typeFilters = null, Regex[] nameFilters = null, Regex[] containerFilters = null) + public static async Task BuildAssetMap(string[] files, string mapName, Game game, string savePath, ExportListType exportListType, ClassIDType[] typeFilters = null, Regex[] nameFilters = null, Regex[] containerFilters = null) { Logger.Info("Building AssetMap..."); try @@ -629,7 +629,7 @@ namespace AssetStudio } } - private static Task ExportAssetsMap(List toExportAssets, Game game, string name, string savePath, ExportListType exportListType, ManualResetEvent resetEvent = null) + private static Task ExportAssetsMap(List toExportAssets, Game game, string name, string savePath, ExportListType exportListType) { return Task.Run(() => { @@ -691,11 +691,9 @@ namespace AssetStudio Logger.Info($"Finished buidling AssetMap with {toExportAssets.Count} assets."); } - - resetEvent?.Set(); }); } - public static async void BuildBoth(string[] files, string mapName, string baseFolder, Game game, string savePath, ExportListType exportListType, ClassIDType[] typeFilters = null, Regex[] nameFilters = null, Regex[] containerFilters = null) + public static async Task BuildBoth(string[] files, string mapName, string baseFolder, Game game, string savePath, ExportListType exportListType, ClassIDType[] typeFilters = null, Regex[] nameFilters = null, Regex[] containerFilters = null) { Logger.Info($"Building Both..."); CABMap.Clear();