作者toyangel (toyangel)
看板C_Sharp
标题Re: [问题] C#使用批次档的问题
时间Tue Dec 6 02:48:55 2011
可以试试把批次档的值读回来做判断
例如
Process p = new Process();
p.StartInfo.FileName = "xxx.bat";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.Start();
string str = "";
while(str != null)
{
str = p.StandardOutput.ReadLine();
...
...
}
※ 引述《markzog21 (残羽星辰)》之铭言:
: 小弟最近写了一个程式
: 有使用到Process
: oThreadA = new Thread(new ThreadStart(A));
: oThreadA.Start();
: oThreadB = new Thread(new ThreadStart(B));
: oThreadB.Start();
: 问题在A的执行绪里面有使用到批次档处理
: 而B执行绪希望等A执行完以後再执行
: 但我不知道C#要怎麽样检查批次档执行的进度
: 我目前的写法是下面
: ---------
: A
: {
: for(int i = 0 ; i < 10000 ;i++)
: {
: using (StreamWriter sw = new StreamWriter(i + ".bat"))
: { xxxxxxxxxxx
: }
: Process.Start(i + ".bat");
: }
: }
: B
: {
: oThreadA.Join();
: xxxxx
: }
: --------------
: 但还是没有办法在所有的批次档跑完後再执行B
: 请问版上 是否可指导迷津一下
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.192.44.213
※ 编辑: toyangel 来自: 123.192.44.213 (12/06 02:49)
1F:推 Flychop:process.waitforexit() 12/14 20:56