本文整理匯總了C#中System.Function.GetParentScope方法的典型用法代碼示例。如果您正苦於以下問題:C# Function.GetParentScope方法的具體用法?C# Function.GetParentScope怎麽用?C# Function.GetParentScope使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Function
的用法示例。
在下文中一共展示了Function.GetParentScope方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Spawn
/// <summary>
/// The spawn function runs a given function or script in a different
/// thread.
/// </summary>
/// <remarks>
/// The spawn function runs a given function or script in a different
/// thread.
/// js> function g() { a = 7; }
/// js> a = 3;
/// 3
/// js> spawn(g)
/// Thread[Thread-1,5,main]
/// js> a
/// 3
/// </remarks>
public static object Spawn(Context cx, Scriptable thisObj, object[] args, Function funObj)
{
Scriptable scope = funObj.GetParentScope();
Runner runner;
if (args.Length != 0 && args[0] is Function)
{
object[] newArgs = null;
if (args.Length > 1 && args[1] is Scriptable)
{
newArgs = cx.GetElements((Scriptable)args[1]);
}
if (newArgs == null)
{
newArgs = ScriptRuntime.emptyArgs;
}
runner = new Runner(scope, (Function)args[0], newArgs);
}
else
{
if (args.Length != 0 && args[0] is Script)
{
runner = new Runner(scope, (Script)args[0]);
}
else
{
throw ReportRuntimeError("msg.spawn.args");
}
}
runner.factory = cx.GetFactory();
Sharpen.Thread thread = new Sharpen.Thread(runner);
thread.Start();
return thread;
}
示例2: GetInstance
private static Rhino.Tools.Shell.Global GetInstance(Function function)
{
Scriptable scope = function.GetParentScope();
if (!(scope is Rhino.Tools.Shell.Global))
{
throw ReportRuntimeError("msg.bad.shell.function.scope", scope.ToString());
}
return (Rhino.Tools.Shell.Global)scope;
}