IronPython調用C#啓動外部進程
import clr
clr.AddReference("System")
import System
#不能像下面這樣用
#clr.AddReference("System.Diagnostics")#這一行就出錯
#事件回調
def on_exit(*arg):
print "exit"
def callProcess(**arg):
app = System.Diagnostics.Process()
app.StartInfo.FileName = arg["appName"]
if arg.has_key("args"):
app.StartInfo.Arguments = arg["args"]
#支持事件
app.EnableRaisingEvents = True
#添加事件處理
app.Exited += on_exit
app.Start()
app.WaitForExit()
print "end"
if __name__ == "__main__":
callProcess(appName = "notepad.exe")