示例#1
0
        public static void ReadProseAfterDelay(ProseRuntime runtime, List <ProseObject> args)
        {
            lock (lockObj) {
                if (args.Count < 2)
                {
                    throw new ArgumentException("ReadProseAfterDelay takes two arguments: @string[delay] @prose[script].");
                }

                //	Parse the args for the delay and the script
                double          seconds = Double.Parse(((StringLiteralObject)args[0]).literal);
                RuntimeRunnable script  = new ProseObjectListReader(args.GetRange(1, args.Count - 1));

                //	Configure the timer
                Timer timer = new Timer(seconds * 1000);
                timer.AutoReset = false;
                timer.Elapsed  += new ElapsedEventHandler(onTimeElapsed);

                timer.Enabled = true;

                //	Add the timer and the script to the list
                timerList.Add(timer);
                scriptList.Add(script);
                runtimeList.Add(runtime);
            }
        }
示例#2
0
文件: Time.cs 项目: FizzyP/Prose
        public static void ReadProseAfterDelay(ProseRuntime runtime, List<ProseObject> args)
        {
            lock(lockObj) {
                if (args.Count < 2)
                    throw new ArgumentException("ReadProseAfterDelay takes two arguments: @string[delay] @prose[script].");

                //	Parse the args for the delay and the script
                double seconds = Double.Parse(((StringLiteralObject) args[0]).literal);
                RuntimeRunnable script = new ProseObjectListReader(args.GetRange(1, args.Count - 1));

                //	Configure the timer
                Timer timer = new Timer(seconds * 1000);
                timer.AutoReset = false;
                timer.Elapsed += new ElapsedEventHandler(onTimeElapsed);

                timer.Enabled = true;

                //	Add the timer and the script to the list
                timerList.Add(timer);
                scriptList.Add(script);
                runtimeList.Add(runtime);
            }
        }