Skip to content
This repository was archived by the owner on Aug 9, 2025. It is now read-only.

Commit 0a498e0

Browse files
author
VioletGiraffe
committed
Further fix for #22
1 parent 3377645 commit 0a498e0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

CPPCheckPlugin/ICodeAnalyzer.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ private void abortThreadIfAny()
3838
{
3939
try
4040
{
41-
_thread.Abort();
41+
_terminateThread = true;
42+
_thread.Join();
4243
}
4344
catch (System.Exception /*ex*/) { }
4445
_thread = null;
@@ -48,6 +49,7 @@ private void abortThreadIfAny()
4849
private void analyzerThreadFunc(string analyzerExePath, string arguments, bool bringOutputToFrontAfterAnalysis)
4950
{
5051
System.Diagnostics.Process process = null;
52+
_terminateThread = false;
5153
try
5254
{
5355
Debug.Assert(!String.IsNullOrEmpty(analyzerExePath));
@@ -79,7 +81,16 @@ private void analyzerThreadFunc(string analyzerExePath, string arguments, bool b
7981
process.BeginOutputReadLine();
8082
process.BeginErrorReadLine();
8183
// Wait for analysis completion
82-
process.WaitForExit();
84+
while (!process.HasExited)
85+
{
86+
if (!_terminateThread)
87+
System.Threading.Thread.Sleep(30);
88+
else
89+
{
90+
process.Kill();
91+
return;
92+
}
93+
}
8394
timer.Stop();
8495
float timeElapsed = timer.ElapsedMilliseconds / 1000.0f;
8596
if (process.ExitCode != 0)
@@ -138,5 +149,6 @@ protected virtual void Dispose(bool disposing)
138149
protected int _numCores;
139150

140151
private System.Threading.Thread _thread = null;
152+
private bool _terminateThread = false;
141153
}
142154
}

0 commit comments

Comments
 (0)