Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Retrieving javascript line index during execution

0
0
Hello rovs,

The following test runs to completion without script termination or infinite recursion, and the output is exactly as expected:
publicclass Test {
    public ScriptEngine Engine { get; set; }
    publicvoid Method1(int index) {
        Console.WriteLine("{0} {1}", index, Engine.GetStackTrace());
    }
    publicvoid Method2(int index) {
        Console.WriteLine("{0} {1}", index, Engine.Script.getStackTrace());
    }
}
engine.AddHostObject("test", new Test { Engine = engine });
engine.Execute(@"
    function getStackTrace() { return new Error().stack; }
    for (var i = 0; i < 1000; i++) { test.Method1(i); }
    for (var i = 0; i < 1000; i++) { test.Method2(i); }
");
Is there something you're doing differently?

Thanks!

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images