How to know who kills my threads

后端 未结 15 744
南旧
南旧 2020-12-05 00:19

I got a thread that is just banishing.. i\'d like to know who is killing my thread and why.

It occurs to me my thread is being killed by the OS, but i\'d like to

15条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 00:59

    I don't know the answer, but some thoughts:

    • Could it be throwing an exception? Have you tried putting a try/catch around the DoSomethingForALongLongTime() call?
    • Are there any points where it exits normally? Try putting some logging on them.
    • Do you get the same behaviour in and out of the debugger? Does the output window in the debugger provide any hints?

    UPDATE

    You said:

    This thread is created by the web server, which continues to run

    If the thread is running inside asp.net then it may be that the thread is being killed when the asp.net worker process recycles, which it will do periodically. You could try turning off worker process recycling and see if that makes any difference.

提交回复
热议问题