CSharpScriptExecution.ExecuteMethodAsync

Executes a complete async method by wrapping it into a class, compiling and instantiating the class and calling the method. This method has to return a result value - it cannot be void!

Class should include full class header (instance type, return value and parameters)

"public async Task HelloWorld(string name) { await Task.Delay(1); return name; }" "public async Task HelloWorld(string name) { await Task.Delay(1); Console.WriteLine(name); }"

Async Method Note: Keep in mind that the method is not cast to that result - it's cast to object so you have to unwrap it: var objTask = script.ExecuteMethod(asyncCodeMethod); // object result var result = await (objTask as Task); // cast and unwrap

public Task<object> ExecuteMethodAsync(string code, string methodName, 
			object[] parameters)

Parameters

code
One or more complete methods.

methodName
Name of the method to call.

parameters
any number of variable parameters

Overloads