I’ve got a DAL library with a repository static class; it’s initialized via singleton pattern (static constructor). There is website that uses this DAL library, and a windows service project in the same solution.
As far as know, there would be two instances of the singleton object, one in each domain of site and WINservice. Is that right?
For the web site app, after some idle time, the domain in unloaded, and so the repo class will be unloaded too, right?
And last question about the winservice: as far as know this domain will never be unloaded, while the service is running, so that the repo object will remain in memory?
PS: What would happen, if I create a subclass object, e.g. worker for winservice, which will use the repo class inside of it.
using (var worker = new worker())
{
//some DAL manipulations
}
Would the repo object be destroyed once I leave the worker context?
Thanks for any help.
Yes
Yes (the rules for recycling the app pool can be setup in IIS)
Yes
No (unless you dispose of it of course)