C# Program to Check Whether the CLR is Shutting Down or Not Using Environment Class
In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information, and time since the last system boot in milliseconds information. By just using some predefined methods we can get the information of the Operating System using the Environment class. Here in this article, we will check whether the CLR(common language runtime) is shutting down or not. So we use the HasShutdownStarted property of the Environment class. This property is used to check whether the CLR is shutting down or the application domain is being unloaded or not. If the CLR is shut down then it will return true. Otherwise, it will return false if the is not CLR is shut down.
In the dot net framework, when an application domain is unloaded by CLR, then it executes finalizers on all the objects that contain finalizer function in that application domain. So when the CLR is shut down, then it will execute finalizers threads on all the objects that have the finalizer function. Hence this property returns true when the finalizer thread is started otherwise returns false.
Return Type: the return type of this property is boolean. Returns true if the CLR is shutting otherwise false.
No! CLR is not shutting down