I am referencing a 3rd party library in an ASP.NET MVC application, because the design of the library, it requires a class (say ClassA
) from it must be instantiated only once and should be disposed after use. So, in my MVC application I defined a static class and instantiated the external ClassA
inside (ClassA
is heavily used). But what's the effective way to dispose the single instance of ClassA
? I believe Application_End
is not the right place. but in what event or method is the right place to do it?
I should consider scenarios iisreset
, application pool recycle and any other cases that server stops or restarts and to make sure the resource is properly disposed.