當前位置: 首頁>>代碼示例>>C#>>正文


C# Function.GetParentScope方法代碼示例

本文整理匯總了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&gt; function g() { a = 7; }
		/// js&gt; a = 3;
		/// 3
		/// js&gt; spawn(g)
		/// Thread[Thread-1,5,main]
		/// js&gt; 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;
		}
開發者ID:hazzik,項目名稱:Rhino.Net,代碼行數:48,代碼來源:Global.cs

示例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;
		}
開發者ID:hazzik,項目名稱:Rhino.Net,代碼行數:9,代碼來源:Global.cs


注:本文中的System.Function.GetParentScope方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。