简体   繁体   English

dotnet崩溃服务是否终止其自己的线程?

[英]Does a dotnet crashing service terminate its own threads?

I have a windows service written in dotNet. 我有一个用dotNet编写的Windows服务。 There is a worker service that spawns worker threads using various Delegate.BeginInvokes. 有一个工作器服务,它使用各种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. 他们可能有或没有获得足够的处理器时间来完成执行-取决于他们在做什么以及Windows转储进程的速度。

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. Windows(2000+)的所有健壮版本都应将您的进程隔离开,因此当它死时,整个进程空间将被转储并回收内存。 If you were accessing unmanaged resources at the time of the crash, then the whole picture changes and the answer is "it depends". 如果您在崩溃时正在访问非托管资源,那么整个情况将发生变化,答案是“取决于情况”。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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