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); } }
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); } }