The script that I have is in the Execute method for SPJobDefinition, which I want to go through every SPSite in the web application. So I have the following code:
foreach (SPSite site in this.WebApplication.Sites) { ... }
The question is, do I need to manage each site? The rule that I usually go through is laid out or placed inside use only if I update it myself. Will this property of objects actually contain fully constructed site objects, from which I will refer only in this code. If so, deleting the sites will be dangerous, as I am modifying another object that might want them. Or vice versa, the Sites property creates objects on demand .. In this case, is it my responsibility to delete them?
Plus, how do I handle if I need it. I canโt use use in this case, and will it cause hold inside the foreach, iterating over the enumeration?
source share