导入 TimerModule 计时器模块

This commit is contained in:
2026-06-18 22:50:46 +08:00
parent fbc7e66491
commit 0dc5889417
21 changed files with 1334 additions and 1 deletions
@@ -0,0 +1,55 @@
using System;
namespace SepCore.Timer
{
/// <summary>
/// 定时任务句柄。
/// </summary>
public readonly struct TimerHandle : IEquatable<TimerHandle>
{
public static readonly TimerHandle Invalid = new TimerHandle(0);
public TimerHandle(int id)
{
Id = id;
}
/// <summary>
/// 获取定时任务编号。
/// </summary>
public int Id
{
get;
}
/// <summary>
/// 获取句柄是否有效。
/// </summary>
public bool IsValid => Id > 0;
public bool Equals(TimerHandle other)
{
return Id == other.Id;
}
public override bool Equals(object obj)
{
return obj is TimerHandle other && Equals(other);
}
public override int GetHashCode()
{
return Id;
}
public static bool operator ==(TimerHandle left, TimerHandle right)
{
return left.Equals(right);
}
public static bool operator !=(TimerHandle left, TimerHandle right)
{
return !left.Equals(right);
}
}
}