Can WaitHandle.WaitOne throw a ThreadAbortException?
Asked Answered
B

0

6

I'm getting the following exception:

Exception of type ThreadAbortException occurred: System.Threading.ThreadAbortException: ThreadAbortException 
at System.Threading.EventWaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext) 
at MyCode.ProcessEvents() 

And I'm confused about how it could happen. I'm sure that I'm not aborting this particular thread, though my code could be aborting a different one (including the thread that sets the WaitHandle). This leads me to believe that either the framework is raising the exception or a threadabortexception for a different thread is bleeding out into this one somehow. Neither of which I thought were possible.

So, If I am not calling Thread.Abort() on this thread, how can it end up with a ThreadAbortException?

Buntline answered 24/9, 2013 at 13:26 Comment(5)
So what's your question. I can't get your point exactly. Is your question how can runtime throw exception in a thread waiting at WaitOne?Benzene
Have clarified the question: I was of the opinion that the only way for a thread to get this exception was if I call thread.abort on it. But I'm not, so i'm baffled how this stack trace is even possibleBuntline
Could you post some repro with small sample program?Benzene
Is this relevant? https://mcmap.net/q/233815/-why-am-i-getting-quot-thread-was-being-aborted-quot-in-asp-net/56778Roguish
Thanks for the responses. Unfortunately, I haven't repro'd the issue. The trace is from logs on a customer server and it happens quite rarely. In my googling, I did see mention of asp.net being able to abort threads but this is c# running on a windows mobile device so didn't think it applied.Buntline

© 2022 - 2024 — McMap. All rights reserved.