.Net CLR 卸载与关闭? [英] .Net CLR Unloading vs shutdown?

查看:28
本文介绍了.Net CLR 卸载与关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是什么导致调用 Finalize 方法?

What Causes Finalize Methods to Be Called ?

此问题的 2 个答案(共 4 个)是:

2 answers( of 4 ) to this question are :

  • CLR 正在卸载 AppDomain 当 AppDomain 卸载时,CLR 认为AppDomain 中没有任何内容可以作为根,以及由以下内容组成的垃圾收集执行所有代.

  • The CLR is unloading an AppDomain When an AppDomain unloads, the CLR considers nothing in the AppDomain to be a root, and a garbage collection consisting of all generations is performed.

CLR 正在关闭 CLR 在进程正常终止时关闭(例如,与通过任务管理器外部关闭相反).

The CLR is shutting down The CLR shuts down when a process terminates normally (as opposed to an external shutdown via Task Manager, for example).

我假设 CLR 正在卸载 AppDomain 是在程序(例如控制台 [exe])被关闭(按关闭/程序正常结束)

I assume that The CLR is unloading an AppDomain is when the program (console [exe] for example) is being closed ( by pressing close / normal end of program)

CLR 正在关闭 怎么样?继续上面的[Exe]程序类比:

  • 这是什么意思?我怎样才能关闭 CLR ...?
  • [在 IIS 世界中] 是否意味着 IIS 重置?

拜托,我可以稍微解释一下吗?

please, can I have small explanation ?

推荐答案

AppDomain 是一个比 Process 更细粒度的单元.一个 Process 可以有多个 AppDomain 实例,每个实例都可以单独卸载.

The AppDomain is a more granular unit than the Process. A Process can can have multiple AppDomain instances, each of which can be unloaded separately.

CLR 关闭是进程终止.

The CLR shutdown is the process terminating.

AppDomain 卸载是每个 AppDomain 单独的.

The AppDomain unloading is each AppDomain separately.

(虽然我个人不会在不检查文档的情况下保证在任何一种情况下都会执行所有终结器等)

(although I would not personally guarantee, without checking the documentation, that all finalizers etc are executed in either case)

举个例子,我在一个长时间运行的自更新windows服务中使用了多个AppDomain实例;当检测到新版本时,它会下拉新的二进制文件,生成一个新的 AppDomain,让它运行,将未来的操作切换到新的 AppDomain,并卸载旧的 AppDomain(当运行操作完成时).

As an example, I use multiple AppDomain instances in a long-running self-updating windows service; when new versions are detected it pulls down the new binaries, spawns a new AppDomain, gets it running, switches future operations to the new AppDomain, and unloads the old AppDomain (when running operations have completed).

这篇关于.Net CLR 卸载与关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆