Can CERs be used to ensure that finalization is never called?

We have a very complex interaction problem in which the thread used to initialize a third-party system must be the same thread that was used to complete it. Failure to do so will result in deadlock. We interact with the WCF service hosted in IIS. Currently, this cleaning is available and, as a rule, works very well. Unfortunately, under heavy load, IIS will do a rough offload and we will never get a dispose call. We can move the shutdown logic to a critical finalizer, but that does not help, since we no longer have access to the initializing topic! For now, our only resource seems to notify the CLR that AppDomain is now probably in a damaged state. However, I am not sure how to do this (or if possible). Maybe this is the usefulness of contracts at the class level, but I admit that I do not quite understand them completely.

EDIT: As an alternative, this can be seen as a thread merge problem in the finalizer. If anyone has a smart solution, I'm all ears :)

+6
source share
1 answer

Try to separate code that depends on this dependency on a stand-alone Windows application, if possible. If it does not work with WCF / IIS, you should avoid conflicts, not fight it.

+1
source

Source: https://habr.com/ru/post/910537/


All Articles