Using ThreadExceptionEventHandler: determine which thread caused the exception
Asked Answered
T

1

2

Using the Application.ThreadExceptionEventHandler, is it possible to determine which thread caused the exception (the thread id)?

The same question applies to using the AppDomain.UnhandledExceptionEventHandler to catch non-UI thread exceptions.

If the answer is no, is there any other way to determine which thread raised the unhandled exception in such cases?

Tommietommy answered 19/8, 2009 at 16:39 Comment(0)
L
2

I haven't checked, but I'd expect the handler to be executed in the thread which threw the exception - in which case Thread.CurrentThread would be what you want. I can't see how it would make much sense for the handler to be executed in any other thread.

Lytta answered 19/8, 2009 at 16:45 Comment(1)
Once again, you are correct :) I ran a test and it proved your pointTommietommy

© 2022 - 2024 — McMap. All rights reserved.