Click or drag to resize

HostFunctionsproc Method

Creates a delegate that invokes a script function and returns no value.

Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.3.5
public Object proc(
	int argCount,
	Object scriptFunc


argCount  Int32
The number of arguments to pass to the script function.
scriptFunc  Object
The script function for which to create a delegate.

Return Value

A new delegate that invokes the specified script function and returns no value.
This function creates a delegate that accepts argCount arguments and returns no value. The type of all parameters is Object. Such a delegate is often useful in strongly typed contexts because of contravariance.
The following code demonstrates delegating a callback to a script function. It assumes that an instance of ExtendedHostFunctions is exposed under the name "host" (see AddHostObject).
// create and populate an array of strings
var StringT = host.type("System.String");
var array = host.newArr(StringT, 3);
array.SetValue("first", 0);
array.SetValue("second", 1);
array.SetValue("third", 2);
// use Array.ForEach to generate console output
var ArrayT = host.type("System.Array");
var ConsoleT = host.type("System.Console");
ArrayT.ForEach(array, host.proc(1, function (value) { ConsoleT.WriteLine(value); }));
See Also