Problem with enabling themes (and modules?)

Topics: Core, Troubleshooting
May 15, 2012 at 1:06 PM
Edited May 15, 2012 at 2:25 PM

I have a module that runs a background thread in a loop.

Whenever Orchard detects a code change, it properly kills the bg thread and the process starts all over.

But, if I enable a theme (same with a module I think) it looks like my bg thread is running at least twice.

Is this a problem in orchard? Or how can I properly detect these kinds of 'internal restarts' so I can manually kill the old bg thread?

edit: Correction! I just debugged it. When I disable a theme, my old bg thread kept running and it create 2 additional instances that are running! Good thing is that all still seems to happen in the same app domain, maybe I can workaround it somehow but a more permanent solution would be nice :)

edit2: Should it aid if I make my services IDisposable (and properly clean up the bg threads) or aren't those disposed when enabling/disabling something?