Skip to content

Commit cf5ce5a

Browse files
committed
Fixed freeze bug
Fixed the problem where including the "debug" argument would cause the program to freeze.
1 parent f55fcea commit cf5ce5a

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

Advanced Papyrus.cs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,17 +164,28 @@ static void RunCompiler(string[] args)
164164
CreateNoWindow = true
165165
}
166166
};
167+
proc.EnableRaisingEvents = true;
168+
proc.OutputDataReceived += new DataReceivedEventHandler(OutputWriter);
169+
proc.ErrorDataReceived += new DataReceivedEventHandler(OutputWriter);
167170
proc.Start();
168-
twOut.WriteLine(proc.StandardOutput.ReadLine());
169-
while((!proc.StandardOutput.EndOfStream) || (!proc.StandardError.EndOfStream)) {
170-
if (!proc.StandardOutput.EndOfStream)
171-
{
172-
twOut.WriteLine(proc.StandardOutput.ReadLine());
173-
}
174-
if (!proc.StandardError.EndOfStream)
175-
{
176-
twError.WriteLine(proc.StandardError.ReadLine());
177-
}
171+
proc.BeginOutputReadLine();
172+
proc.BeginErrorReadLine();
173+
proc.WaitForExit();
174+
}
175+
176+
static void OutputWriter(object sender, DataReceivedEventArgs args)
177+
{
178+
if (args.Data != null)
179+
{
180+
twOut.WriteLine(args.Data);
181+
}
182+
}
183+
184+
static void ErrorWriter(object sender, DataReceivedEventArgs args)
185+
{
186+
if (args.Data != null)
187+
{
188+
twError.WriteLine(args.Data);
178189
}
179190
}
180191
}

Advanced Papyrus.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)