0
假設我們有IronPython中下面的代碼:從C#調用IronPython的功能IronPython的運行時間進行處理後
def hello():
print "Hello from Python"
我們稱之爲功能hello()
在下面的C#代碼:
private static void GetPythonFunction()
{
ScriptRuntime scriptRuntime = IronPython.Hosting.Python.CreateRuntime();
ScriptScope scope = scriptRuntime.ExecuteFile(@"Python\helloFunc.py");
Action hello = scope.GetVariable<Action>("hello");
hello();
scriptRuntime.Shutdown();
hello(); // after IronPython runtime was disposed
}
這給我們造成:
Hello from Python
Hello from Python
爲什麼第二個電話hello()
工程雙絞線即使運行時環境被丟棄?