Detect module being disabled

Topics: Customizing Orchard, Writing modules
Jul 2, 2012 at 8:33 AM

I have a module that activates a profiler once enabled (it calls a static method to do so), and now I wonder how I can detect my module (or feature) being disabled to I can call the static method to stop the profiler (by calling another static method).

How can I handle this?

Jul 2, 2012 at 8:35 AM

You can't. There is no reliable way to do this, I think. For all you know, the module may be deleted from disk.

Jul 2, 2012 at 8:45 AM

Thing is, that even when I disable the module (it is the only one that references this profiler dll), the profiler keeps running.

Jul 2, 2012 at 9:05 PM
Edited Jul 2, 2012 at 9:05 PM

Although it's not reliable as Bertrand mentioned, you could get a little closer by implementing IFeatureEventHandler. I believe its Disabled method is invoked when a feature is disabled, but I'm not sure.