Revert "Made calls sync that were giving me issues and built out the path for blank.ini"

This reverts commit 904d314697.
This commit is contained in:
Zesty Fernandez 2022-07-14 08:47:18 -07:00
parent 3f6530f715
commit 66bb454fe9

View file

@ -587,10 +587,10 @@ namespace UWUVCI_AIO_WPF
Settings.Default.Save();
ArePathsSet();
Task.Run(() => UpdateAsync(false));
Task.Run(async () => await UpdateAsync(false));
Task.Run(() => toolCheckAsync());
Task.Run(() => BaseCheck());
Task.Run(async () => await toolCheckAsync());
Task.Run(async () => await BaseCheck());
GameConfiguration = new GameConfig();
if (!ValidatePathsStillExist() && Settings.Default.SetBaseOnce && Settings.Default.SetOutOnce)
@ -1203,18 +1203,16 @@ namespace UWUVCI_AIO_WPF
if (await CheckForInternetConnectionAsync())
{
Progress = 0;
Task.Run(() =>
await Task.Run(async () =>
{
double stuff = 100 / test.Count;
foreach (string s in test)
{
DownloadBaseAsync(s, this);
await DownloadBaseAsync(s, this);
Progress += Convert.ToInt32(stuff);
}
Progress = 100;
});
DownloadWait dw = new DownloadWait("Downloading needed Data - Please Wait", "", this);
try
{
@ -1248,18 +1246,16 @@ namespace UWUVCI_AIO_WPF
Directory.CreateDirectory(@"bin\bases");
var test = GetMissingVCBs();
Progress = 0;
Task.Run(() =>
await Task.Run(async() =>
{
double stuff = 100 / test.Count;
foreach (string s in test)
{
DownloadBaseAsync(s, this);
await DownloadBaseAsync(s, this);
Progress += Convert.ToInt32(stuff);
}
Progress = 100;
});
DownloadWait dw = new DownloadWait("Downloading needed Data - Please Wait", "", this);
try
{
@ -1291,8 +1287,7 @@ namespace UWUVCI_AIO_WPF
if (await CheckForInternetConnectionAsync())
{
string[] bases = ToolCheck.ToolNames;
Progress = 0;
Task.Run(() =>
await Task.Run(() =>
{
Progress = 0;
double l = 100 / bases.Length;
@ -1302,8 +1297,8 @@ namespace UWUVCI_AIO_WPF
DownloadToolAsync(s, this);
Progress += Convert.ToInt32(l);
}
});
Progress = 100;
});
DownloadWait dw = new DownloadWait("Updating Tools - Please Wait", "", this);
try
@ -1403,15 +1398,13 @@ namespace UWUVCI_AIO_WPF
if (Task.Run(() => CheckForInternetConnectionAsync()).GetAwaiter().GetResult())
{
string[] bases = { "bases.vcbnds", "bases.vcbn64", "bases.vcbgba", "bases.vcbsnes", "bases.vcbnes", "bases.vcbtg16", "bases.vcbmsx", "bases.vcbwii" };
Task.Run(() =>
{
await Task.Run(async () => {
Progress = 0;
double l = 100 / bases.Length;
foreach (string s in bases)
{
DeleteBase(s);
DownloadBaseAsync(s, this);
await DownloadBaseAsync(s, this);
GameConsoles g = new GameConsoles();
if (s.Contains("nds")) g = GameConsoles.NDS;
@ -1757,8 +1750,7 @@ namespace UWUVCI_AIO_WPF
using (var client = new WebClient())
{
var fixname = name.Split('\\');
var downloadLink = Task.Run(() => getDownloadLinkAsync(name, false)).GetAwaiter().GetResult();
client.DownloadFile(downloadLink, fixname[fixname.Length -1]);
await client.DownloadFileTaskAsync(await getDownloadLinkAsync(name, false), fixname[fixname.Length -1]);
}
}catch(Exception e)
{
@ -1912,7 +1904,7 @@ namespace UWUVCI_AIO_WPF
foreach (MissingTool m in missingTools)
{
DownloadToolAsync(m.Name,this);
await DownloadToolAsync(m.Name,this);
}
@ -1933,6 +1925,7 @@ namespace UWUVCI_AIO_WPF
}
private void ThreadDownload(List<MissingTool> missingTools)
{
var thread = new Thread(() =>
{
double l = 100 / missingTools.Count;
@ -1942,17 +1935,8 @@ namespace UWUVCI_AIO_WPF
{
if (m.Name == "blank.ini")
{
//somehow the current directory is different, probably because of the async call
//looks to be different each time so we are doing some dumb path builder
var blankPath = Directory.GetCurrentDirectory();
if (!blankPath.Contains("bin"))
blankPath = Path.Combine(blankPath, "bin");
if (!blankPath.Contains("Tools"))
blankPath = Path.Combine(blankPath, "Tools");
if (!blankPath.Contains("blank.ini"))
blankPath = Path.Combine("blank.ini");
File.CreateText(blankPath);
StreamWriter sw = new StreamWriter(Path.Combine(Directory.GetCurrentDirectory(), "bin", "Tools", "blank.ini"));
sw.Close();
}
else
{
@ -1962,9 +1946,11 @@ namespace UWUVCI_AIO_WPF
Progress += Convert.ToInt32(l);
}
Progress = 100;
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
private void timer_Tick2(object sender, EventArgs e)
{
@ -2456,7 +2442,7 @@ namespace UWUVCI_AIO_WPF
ValidatePathsStillExist();
if (await CheckForInternetConnectionAsync())
{
Task.Run(() => { Injection.Download(this); });
await Task.Run(async () => { Injection.Download(this); });
DownloadWait dw = new DownloadWait("Downloading Base - Please Wait", "", this);
try