c#语言可以调用python程序问题,,我在一个winform的
c#语言可以调用python程序问题,,我在一个winform的
我在一个winform的c#程序里通过process调用python程序,这个python程序里有多线程。现在问题是我调用的python程序可以跑,但是跑一会就不能运行了,但是我如果单独运行python就没有问题,这是为什么。。` publ
ic void RunPythonScript(string path, string args = "") { path = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "script\\" + path; p.StartInfo.FileName = "python.exe"; string sArguments = "\"" + path + "\""; if (args.Length > 0) { sArguments += " " + args; } //p.StartInfo.WorkingDirectory = "D:\\"; p.StartInfo.Arguments = sArguments; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); //p.CloseMainWindow(); //p.WaitForExit(); }`
把下面的这行代码取消注释就可以了。前提你这个操作是在主线程之外。不然会阻塞。
//p.WaitForExit();
编橙之家文章,
相关内容
- 程序员学习哪门语言最有前景?,程序员门语言前景,r
- 求Python课题,软件工程方向最好,python软件工程,这学期
- 用Python如何抓到新浪微博前十话题求方法,python新浪
- python语法问题求助,django 1.5 自定义user模型,pythondja
- python类对象属性封装的相关问题求助,python问题求助
- 求大神看下这个python 类的使用模式有什么问题,大神
- Python如何将set对象存入redis后并将其转化为json格式,
- 请问Python2.7 Ubuntu14.10 pip1.5.6提示readline()是什么错误,
- python数据库操作数据类型转换问题,python数据类型,数据
- 求大神帮看下python代码中type作用是什么,pythontype,imp
评论关闭