My class contains an unmanaged system object member (a user profile handle) that is initialized in the static constructor. Conversely, I need to free the object when the class (not object instances) is destroyed, but I've never heard of a static destructor.
Perhaps I could use Environment.HasShutdownStarted in the finalizer, but all instances could have already been gc'd when the AppDomain unloads and the code wouldn't run.
Perhaps I could use the AppDomain.Unload event to run my code.
Any thoughts?
Perhaps I could use Environment.HasShutdownStarted in the finalizer, but all instances could have already been gc'd when the AppDomain unloads and the code wouldn't run.
Perhaps I could use the AppDomain.Unload event to run my code.
Any thoughts?