예제 #1
0
        public static List <LogInfo> Wait(EngineState s, CodeCommand cmd)
        {
            List <LogInfo> logs = new List <LogInfo>();

            Debug.Assert(cmd.Info.GetType() == typeof(CodeInfo_Wait));
            CodeInfo_Wait info = cmd.Info as CodeInfo_Wait;

            if (!NumberHelper.ParseInt32(info.Second, out int second))
            {
                logs.Add(new LogInfo(LogState.Error, $"Argument [{info.Second}] is not a valid integer"));
                return(logs);
            }

            if (second < 0)
            {
                logs.Add(new LogInfo(LogState.Error, $"Argument [{info.Second}] should be larger than 0"));
                return(logs);
            }

            Task.Delay(TimeSpan.FromSeconds(second)).Wait();

            logs.Add(new LogInfo(LogState.Success, $"Slept [{info.Second}] seconds", cmd));

            return(logs);
        }
예제 #2
0
        public static List <LogInfo> Wait(EngineState s, CodeCommand cmd)
        {
            List <LogInfo> logs = new List <LogInfo>();

            Debug.Assert(cmd.Info.GetType() == typeof(CodeInfo_Wait));
            CodeInfo_Wait info = cmd.Info as CodeInfo_Wait;

            if (NumberHelper.ParseInt32(info.Second, out int second) == false)
            {
                throw new InvalidCodeCommandException($"Argument [{info.Second}] is not valid number", cmd);
            }

            Task.Delay(second * 1000).Wait();

            logs.Add(new LogInfo(LogState.Success, $"Slept [{info.Second}] seconds", cmd));

            return(logs);
        }