I have an external library that my code calls that sometimes hangs forever (but only on production!). I put the part that hangs into a seperate thread so I could just kill it and try again if it times out using the following, but it appears to hang when calling abort:
var triesLeft = 5;
while (triesLeft > 0)
{
var mre = new ManualResetEvent(false);
var t = new Thread(_ => {
MethodThatHangsForever10PercentOfTheTime();
mre.Set();
});
t.start();
if (mre.WaitOne(TimeSpan.FromMinutes(20)))
{
break; // Success!
}
triesLeft--;
log("this prints once");
t.abort();
log("this never prints");
}
}
Is it possible that the spawned thread causes the main thread to hang when calling abort on it?