refactor!: Use Func<Task> for scheduled tasks
This commit is contained in:
parent
647d7c4a1c
commit
bc8eb1ac0d
5 changed files with 98 additions and 66 deletions
|
|
@ -1,4 +1,6 @@
|
|||
namespace Xorog.UniversalExtensions;
|
||||
using Xorog.UniversalExtensions.Entities;
|
||||
|
||||
namespace Xorog.UniversalExtensions;
|
||||
|
||||
internal static class Internal
|
||||
{
|
||||
|
|
@ -79,43 +81,9 @@ internal static class Internal
|
|||
}
|
||||
}
|
||||
|
||||
public class InternalSheduler
|
||||
internal class InternalScheduler
|
||||
{
|
||||
public static Dictionary<string, ScheduledTask> RegisteredScheduledTasks { get; internal set; } = new Dictionary<string, ScheduledTask>();
|
||||
|
||||
public class ScheduledTask
|
||||
{
|
||||
public ScheduledTask()
|
||||
{
|
||||
this.Uid = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The unique identifier of this task.
|
||||
/// </summary>
|
||||
public string Uid { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The custom data asscociated with this task.
|
||||
/// </summary>
|
||||
public object? CustomData { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time this task will run.
|
||||
/// </summary>
|
||||
public DateTime? RunTime { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="CancellationTokenSource"/> to prematurely dequeue this task.
|
||||
/// </summary>
|
||||
internal CancellationTokenSource? TokenSource { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Delete this task.
|
||||
/// </summary>
|
||||
public void Delete() =>
|
||||
ScheduledTaskExtensions.DeleteScheduledTask(Uid);
|
||||
}
|
||||
}
|
||||
|
||||
public class HumanReadableTimeFormatConfig
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue