public async void Run(string userIds) { var userArr = userIds.Split(','); foreach (var u in userArr) { await AutoTask.Run(u); } }
/// <summary> /// 定时器回调 /// </summary> /// <paramref name="state"></paramref> private void TimerCallBack(object state) { Console.WriteLine("自动执行一次:" + DateTime.Now); AutoTask.RunAll().Wait(); this.NextTime = this.NextTime.AddDays(1); var timeSpan = this.NextTime - DateTime.Now; if (timeSpan.Milliseconds < 0) { var now = DateTime.Now; timeSpan = now.AddMinutes(1) - now; } this.timer.Change(timeSpan, Timeout.InfiniteTimeSpan); Console.WriteLine("下次执行时间:" + this.NextTime); }