public void Start() { if (token != null && !token.IsCancellationRequested) { token.Cancel(); } token = new CancellationTokenSource(); var startState = new AgvMissionServiceState { State = AgvMissionServiceStateEnum.INFO, Message = "小车管理服务启动", ErrorCode = AgvMissionServiceErrorCodeEnum.NORMAL }; ShowLogEvent?.Invoke(startState.ToString()); while (!token.IsCancellationRequested) { missionContext.Init(); foreach (var item in missionStates) { if (item.CanRequest()) { ShowLogEvent?.Invoke($"【Time:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】{item.Condition()}"); item.Handle(); } } missionContext.PushTask(); Thread.Sleep(1000); } }