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")