33 lines
917 B
C#
Raw Normal View History

2023-05-11 23:11:39 -04:00
using SPTInstaller.Interfaces;
using SPTInstaller.Models;
using System.Threading.Tasks;
namespace SPTInstaller.Installer_Tasks;
internal class TestTask : InstallerTaskBase
2023-05-11 23:11:39 -04:00
{
public static TestTask FromRandomName() => new TestTask($"Test Task #{new Random().Next(0, 9999)}");
2024-05-01 10:31:55 -04:00
public TestTask(string name) : base(name)
2023-05-11 23:11:39 -04:00
{
}
2024-05-01 10:31:55 -04:00
public async override Task<IResult> TaskOperation()
{
var total = 4;
var interval = TimeSpan.FromSeconds(1);
2024-05-01 10:31:55 -04:00
for (var i = 0; i < total; i++)
2023-05-11 23:11:39 -04:00
{
var count = i + 1;
var progressMessage = $"Running Task: {Name}";
var progress = (int)Math.Floor((double)count / total * 100);
2024-05-01 10:31:55 -04:00
SetStatus(progressMessage, $"Details: ({count}/{total})", progress);
2024-05-01 10:31:55 -04:00
await Task.Delay(interval);
2023-05-11 23:11:39 -04:00
}
2024-05-01 10:31:55 -04:00
return Result.FromSuccess();
2023-05-11 23:11:39 -04:00
}
}