Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'WorkerForm.cs')
-rw-r--r--WorkerForm.cs47
1 files changed, 19 insertions, 28 deletions
diff --git a/WorkerForm.cs b/WorkerForm.cs
index 815b3396..6a4adeeb 100644
--- a/WorkerForm.cs
+++ b/WorkerForm.cs
@@ -1465,42 +1465,33 @@ namespace com.clusterrr.hakchi_gui
var outputStr = new StringBuilder();
var errorStr = new StringBuilder();
process.Start();
- if (onLineOutput != null)
+ var line = new StringBuilder();
+ while (!process.HasExited || !process.StandardOutput.EndOfStream || !process.StandardError.EndOfStream)
{
- var line = new StringBuilder();
- while (!process.HasExited || !process.StandardOutput.EndOfStream || !process.StandardError.EndOfStream)
+ while (!process.StandardOutput.EndOfStream)
{
- while (!process.StandardOutput.EndOfStream)
+ var b = process.StandardOutput.Read();
+ if (b >= 0)
{
- var b = process.StandardOutput.Read();
- if (b >= 0)
+ if ((char)b != '\n' && (char)b != '\r')
{
- if ((char)b != '\n' && (char)b != '\r')
- {
- line.Append((char)b);
- }
- else
- {
- if (line.Length > 0)
- onLineOutput(line.ToString());
- line.Length = 0;
- }
- outputStr.Append((char)b);
+ line.Append((char)b);
}
+ else
+ {
+ if (onLineOutput != null && line.Length > 0)
+ onLineOutput(line.ToString());
+ line.Length = 0;
+ }
+ outputStr.Append((char)b);
}
- if (!process.StandardError.EndOfStream)
- errorStr.Append(process.StandardError.ReadToEnd());
- Thread.Sleep(100);
}
- if (line.Length > 0)
- onLineOutput(line.ToString());
- }
- else
- {
- process.WaitForExit();
- outputStr.Append(process.StandardOutput.ReadToEnd());
- errorStr.Append(process.StandardError.ReadToEnd());
+ if (!process.StandardError.EndOfStream)
+ errorStr.Append(process.StandardError.ReadToEnd());
+ Thread.Sleep(100);
}
+ if (onLineOutput != null && line.Length > 0)
+ onLineOutput(line.ToString());
output = Encoding.GetEncoding(866).GetBytes(outputStr.ToString());
Debug.WriteLineIf(outputStr.Length > 0 && outputStr.Length < 300, "Output:\r\n" + outputStr);