namespace OSS.Tools.TimerJob; internal class InternalTimerExecutor : BaseJobExecutor { private readonly Func _executingAction; private readonly Func? _stopAction; /// public InternalTimerExecutor(string triggerName, Func _executingAction, Func? stopAction) : base(triggerName) { this._executingAction = _executingAction ?? throw new ArgumentNullException(nameof(_executingAction), $"未能设置定时器({triggerName})有效执行方法!"); _stopAction = stopAction; } protected override Task OnStarting(CancellationToken cancellationToken) { return _executingAction?.Invoke(cancellationToken) ?? Task.CompletedTask; } protected override Task OnStopping(CancellationToken cancellationToken) { return _stopAction?.Invoke(cancellationToken) ?? Task.CompletedTask; } }