public void EventHandler(object source, ElapsedEventArgs args) { VsaEngine vsa = (Microsoft.JScript.Vsa.VsaEngine)engine.Engine; try { int handle = window.Document.RootElement.SuspendRedraw(60000); if (scriptOrClosure is Closure) { Closure closure = (Closure)scriptOrClosure; Object[] closureArgs = new Object[0]; GlobalScope scope = vsa.GetMainScope(); closure.Invoke(closure.GetParent(), closureArgs); } else { ((JScriptEngine)engine).Evaluate(scriptOrClosure.ToString(), null); } window.Document.RootElement.UnsuspendRedraw(handle); } catch (Exception e) { //XXX: System.Windows.Forms.MessageBox.Show(scriptOrClosure.ToString() + "\n\n" + e.Message + "\n" + e.StackTrace + "\n" + e.ToString()); Console.Error.WriteLine(scriptOrClosure.ToString() + "\n\n" + e.Message + "\n" + e.StackTrace + "\n" + e.ToString()); } // Clear this if we can if (!timer.AutoReset) { ClearMonitor("" + timer.GetHashCode()); } }
// Perform a constructor call on this object. internal override Object Construct(VsaEngine engine, Object[] args) { String parameters; String body; String defn; int index; JSParser parser; JFunction func; // Collect up the parameters and body. if (args.Length == 0) { parameters = String.Empty; body = String.Empty; } else if (args.Length == 1) { parameters = String.Empty; body = Convert.ToString(args[0]); } else { parameters = Convert.ToString(args[0]); for (index = 1; index < (args.Length - 1); ++index) { parameters = String.Concat(parameters, ",", Convert.ToString(args[index])); } body = Convert.ToString(args[args.Length - 1]); } // Build a complete function definition and parse it. defn = "function (" + parameters + ") { " + body + " }"; parser = new JSParser(new Context(defn)); func = parser.ParseFunctionSource(); // Build the function object and return it. return(new FunctionObject (EngineInstance.GetEngineInstance(engine) .GetFunctionPrototype(), func, engine.GetMainScope())); }
public void EventHandler( IEvent @event) { VsaEngine vsa = (Microsoft.JScript.Vsa.VsaEngine)closure.engine; try { //int handle = window.Document.RootElement.SuspendRedraw(60000); Object[] args = new Object[1]; args[0] = ScriptableObject.CreateWrapper(@event); GlobalScope scope = vsa.GetMainScope(); closure.Invoke(closure.GetParent(), args); //window.Document.RootElement.UnsuspendRedraw(handle); } catch (Exception e) { //XXX: Do something about this! System.Windows.Forms.MessageBox.Show(e.Message + "\n" + e.StackTrace + "\n" + e.ToString()); Console.WriteLine("AAHHH!!!! " + e.ToString()); } }