Skip to content

Commit

Permalink
use better task wait
Browse files Browse the repository at this point in the history
  • Loading branch information
laolarou726 committed Nov 5, 2024
1 parent 1220ad8 commit bfc91fc
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public MicrosoftAuthenticator()

public AuthResultBase Auth(bool userField = false)
{
return AuthTaskAsync(userField).Result;
return AuthTaskAsync(userField).GetAwaiter().GetResult();
}

public async Task<AuthResultBase> AuthTaskAsync(bool userField = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public AuthResultBase Auth(bool userField = false)
/// <returns></returns>
public Task<AuthResultBase> AuthTaskAsync(bool userField)
{
return Task.Run(() => Auth());
return Task.FromResult(Auth());
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class YggdrasilAuthenticator : IAuthenticator
/// <returns></returns>
public AuthResultBase Auth(bool userField = false)
{
return AuthTaskAsync().Result;
return AuthTaskAsync().GetAwaiter().GetResult();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class DefaultResourceCompleter : IResourceCompleter

public TaskResult<ResourceCompleterCheckResult?> CheckAndDownload()
{
return CheckAndDownloadTaskAsync().Result;
return CheckAndDownloadTaskAsync().GetAwaiter().GetResult();
}

public async Task<TaskResult<ResourceCompleterCheckResult?>> CheckAndDownloadTaskAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class FabricInstaller : InstallerBase, IFabricInstaller

public string Install()
{
return InstallTaskAsync().Result;
return InstallTaskAsync().GetAwaiter().GetResult();
}

public async Task<string> InstallTaskAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public partial class HighVersionForgeInstaller : InstallerBase, IForgeInstaller

public ForgeInstallResult InstallForge()
{
return InstallForgeTaskAsync().Result;
return InstallForgeTaskAsync().GetAwaiter().GetResult();
}

ForgeInstallResult GetCorruptedFileResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public string DownloadUrlRoot

public ForgeInstallResult InstallForge()
{
return InstallForgeTaskAsync().Result;
return InstallForgeTaskAsync().GetAwaiter().GetResult();
}

public async Task<ForgeInstallResult> InstallForgeTaskAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class LiteLoaderInstaller : InstallerBase, ILiteLoaderInstaller

public string Install()
{
return InstallTaskAsync().Result;
return InstallTaskAsync().GetAwaiter().GetResult();
}

public async Task<string> InstallTaskAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed class CurseForgeInstaller : ModPackInstallerBase, ICurseForgeInsta

public void Install()
{
InstallTaskAsync().Wait();
InstallTaskAsync().GetAwaiter().GetResult();
}

public static async Task<(string? FileName, string? Url)> TryGuessModDownloadLink(long fileId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public sealed class ModrinthInstaller : ModPackInstallerBase, IModrinthInstaller

public void Install()
{
InstallTaskAsync().Wait();
InstallTaskAsync().GetAwaiter().GetResult();
}

public async Task InstallTaskAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class OptifineInstaller : InstallerBase, IOptifineInstaller

public string Install()
{
return InstallTaskAsync().Result;
return InstallTaskAsync().GetAwaiter().GetResult();
}

public async Task<string> InstallTaskAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class QuiltInstaller : InstallerBase, IQuiltInstaller

public string Install()
{
return InstallTaskAsync().Result;
return InstallTaskAsync().GetAwaiter().GetResult();
}

public async Task<string> InstallTaskAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public event EventHandler<LaunchLogEventArgs> LaunchLogEventDelegate
/// <returns></returns>
public virtual LaunchResult Launch(LaunchSettings settings)
{
return LaunchTaskAsync(settings).Result;
return LaunchTaskAsync(settings).GetAwaiter().GetResult();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public event EventHandler<GameResourceInfoResolveEventArgs> GameResourceInfoReso

public virtual IEnumerable<IGameResource> ResolveResource()
{
return ResolveResourceAsync().ToListAsync().Result;
return ResolveResourceAsync().ToListAsync().GetAwaiter().GetResult();
}

public void Dispose()
Expand Down

0 comments on commit bfc91fc

Please sign in to comment.