Make async saving as singleton
Don't need an extra Task for save task with no timeout.
This commit is contained in:
@@ -20,9 +20,9 @@ using VRage.Utils;
|
|||||||
namespace Torch.Patches
|
namespace Torch.Patches
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A copy of <see cref="MyAsyncSaving"/> except with decent async support.
|
/// A copy of <see cref="MyAsyncSaving"/> except with C# async support.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TorchAsyncSaving
|
public static class TorchAsyncSaving
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves the game asynchronously
|
/// Saves the game asynchronously
|
||||||
@@ -34,6 +34,8 @@ namespace Torch.Patches
|
|||||||
public static Task<GameSaveResult> Save(ITorchBase torch, int timeoutMs = -1, string newSaveName = null)
|
public static Task<GameSaveResult> Save(ITorchBase torch, int timeoutMs = -1, string newSaveName = null)
|
||||||
{
|
{
|
||||||
Task<GameSaveResult> task = SaveInternal(torch, newSaveName);
|
Task<GameSaveResult> task = SaveInternal(torch, newSaveName);
|
||||||
|
if (timeoutMs == -1)
|
||||||
|
return task;
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
// ReSharper disable once ConvertIfStatementToReturnStatement
|
// ReSharper disable once ConvertIfStatementToReturnStatement
|
||||||
|
Reference in New Issue
Block a user