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:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2018-02-22 17:03:54 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2018-02-22 17:03:54 +0300
commit1c110985ebf3c65928ab976de83067149cce2946 (patch)
tree12a82fa78254ccbe3be13dbe06cc3296ef06b785 /WorkerForm.cs
parentdca65b2c83fd8376fc0b20cfb794edb74c96c0a8 (diff)
More fixes
Diffstat (limited to 'WorkerForm.cs')
-rw-r--r--WorkerForm.cs48
1 files changed, 28 insertions, 20 deletions
diff --git a/WorkerForm.cs b/WorkerForm.cs
index db01067d..2b353e90 100644
--- a/WorkerForm.cs
+++ b/WorkerForm.cs
@@ -1475,34 +1475,42 @@ namespace com.clusterrr.hakchi_gui
Debug.WriteLine("Directory: " + directory);
var outputStr = new StringBuilder();
var errorStr = new StringBuilder();
- process.Start();
- var line = new StringBuilder();
- while (!process.HasExited || !process.StandardOutput.EndOfStream || !process.StandardError.EndOfStream)
+ try
{
- while (!process.StandardOutput.EndOfStream)
+ process.Start();
+ var line = new StringBuilder();
+ while (!process.HasExited || !process.StandardOutput.EndOfStream || !process.StandardError.EndOfStream)
{
- var b = process.StandardOutput.Read();
- if (b >= 0)
+ while (!process.StandardOutput.EndOfStream)
{
- if ((char)b != '\n' && (char)b != '\r')
- {
- line.Append((char)b);
- }
- else
+ var b = process.StandardOutput.Read();
+ if (b >= 0)
{
- if (onLineOutput != null && line.Length > 0)
- onLineOutput(line.ToString());
- line.Length = 0;
+ if ((char)b != '\n' && (char)b != '\r')
+ {
+ line.Append((char)b);
+ }
+ else
+ {
+ if (onLineOutput != null && line.Length > 0)
+ onLineOutput(line.ToString());
+ line.Length = 0;
+ }
+ outputStr.Append((char)b);
}
- outputStr.Append((char)b);
}
+ if (!process.StandardError.EndOfStream)
+ errorStr.Append(process.StandardError.ReadToEnd());
+ Thread.Sleep(100);
}
- if (!process.StandardError.EndOfStream)
- errorStr.Append(process.StandardError.ReadToEnd());
- Thread.Sleep(100);
+ if (onLineOutput != null && line.Length > 0)
+ onLineOutput(line.ToString());
+ }
+ catch (ThreadAbortException ex)
+ {
+ if (!process.HasExited) process.Kill();
+ throw ex;
}
- 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);