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

New Post: Passing Action/Func into JS?

0
0
Hello!

What you're doing should work. The delegate may not appear to be a JavaScript function (that is, the typeof operator would return "object" rather than "function"), but it should be invocable just like a function.

For example, this code prints "Hello!" as expected:
engine.Execute("function foo(x) { x(); }");
engine.Script.foo(new Action(() => Console.WriteLine("Hello!")));
Are you doing something differently?

Cheers!

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images