Make async saving as singleton

Don't need an extra Task for save task with no timeout.
This commit is contained in:
Westin Miller
2018-01-05 22:08:08 -08:00
parent 383c9b9a33
commit 0a75d57cf9

View File

@@ -20,9 +20,9 @@ using VRage.Utils;
namespace Torch.Patches
{
/// <summary>
/// A copy of <see cref="MyAsyncSaving"/> except with decent async support.
/// A copy of <see cref="MyAsyncSaving"/> except with C# async support.
/// </summary>
public class TorchAsyncSaving
public static class TorchAsyncSaving
{
/// <summary>
/// Saves the game asynchronously
@@ -34,6 +34,8 @@ namespace Torch.Patches
public static Task<GameSaveResult> Save(ITorchBase torch, int timeoutMs = -1, string newSaveName = null)
{
Task<GameSaveResult> task = SaveInternal(torch, newSaveName);
if (timeoutMs == -1)
return task;
return Task.Run(() =>
{
// ReSharper disable once ConvertIfStatementToReturnStatement