简体   繁体   中英

Does a dotnet crashing service terminate its own threads?

I have a windows service written in dotNet. There is a worker service that spawns worker threads using various Delegate.BeginInvokes. When the service crashes are those threads going to be cleaned up automatically? And if so, when?

All threads created by your process are inside that process. When your application crashes your process dies, and all threads in that process are terminated abruptly. They are not terminated friendly-like (they're not given an abort signal or anything), they are just killed. They may or may not be given enough processor time to finish executing -- rather depends on what they were doing, and how fast Windows dumps the process.

All robust versions of Windows (2000+) should have your process segregated, so when it dies the whole process space is dumped and the memory is reclaimed. If you were accessing unmanaged resources at the time of the crash, then the whole picture changes and the answer is "it depends".

仅当服务终止并从内存中卸载时

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM