not yet used ...
This commit is contained in:
@ -19,25 +19,26 @@ namespace Yavsc.Abstract.IT
|
|||||||
|
|
||||||
public virtual int Run()
|
public virtual int Run()
|
||||||
{
|
{
|
||||||
Process latest = null;
|
|
||||||
Queue<Process> runQueue = new Queue<Process>();
|
Queue<Process> runQueue = new Queue<Process>();
|
||||||
Queue<Task> joints = new Queue<Task>();
|
Queue<Task> joints = new Queue<Task>();
|
||||||
if (Pipe.Length == 0) return -1;
|
if (Pipe.Length == 0) return -1;
|
||||||
if (Pipe.Length == 1)
|
if (Pipe.Length == 1)
|
||||||
{
|
{
|
||||||
latest = Pipe[0].Start();
|
Process singlecmd = Pipe[0].Start();
|
||||||
latest.WaitForExit();
|
singlecmd.WaitForExit();
|
||||||
return latest.ExitCode;
|
return singlecmd.ExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < Pipe.Length; i++)
|
Command cmd = Pipe[0];
|
||||||
|
Process newProcess = cmd.Start(WorkingDir, false, true);
|
||||||
|
Process latest = newProcess;
|
||||||
|
Task ending = Task.Run(() => { latest.WaitForExit(); });
|
||||||
|
for (int i = 1; i < Pipe.Length; i++)
|
||||||
{
|
{
|
||||||
Process newProcess = null;
|
joints.Enqueue(ending);
|
||||||
var cmd = Pipe[i];
|
cmd = Pipe[i];
|
||||||
bool isNotLast = (i + 1) >= Pipe.Length;
|
bool isNotLast = i < Pipe.Length;
|
||||||
|
|
||||||
if (latest != null) // i.e. isNotFirst
|
|
||||||
{
|
|
||||||
newProcess = cmd.Start(WorkingDir, true, isNotLast);
|
newProcess = cmd.Start(WorkingDir, true, isNotLast);
|
||||||
var jt = Task.Run(async () =>
|
var jt = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
@ -49,13 +50,7 @@ namespace Yavsc.Abstract.IT
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
joints.Enqueue(jt);
|
joints.Enqueue(jt);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newProcess = cmd.Start(WorkingDir, false, isNotLast);
|
|
||||||
Task ending = Task.Run(() => { latest.WaitForExit(); });
|
|
||||||
joints.Enqueue(ending);
|
|
||||||
}
|
|
||||||
latest = newProcess;
|
latest = newProcess;
|
||||||
runQueue.Enqueue(latest);
|
runQueue.Enqueue(latest);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user