namespace MasstransferCommon.Scheduler; /// /// 延时定时任务 /// public class DelayScheduler { private Timer _timer; private Action _action; public void Schedule(Action action, TimeSpan delay) { _action = action; _timer = new Timer(TimerCallback, null, delay, Timeout.InfiniteTimeSpan); } private void TimerCallback(object? state) { _timer?.Dispose(); _action?.Invoke(); } }