vinyel23
asked on
Singleton Problems
I have an issue with singleton implementation in C#, my business object has a 3 hash tables this class follows a singleton pattern. I have the following test scenario.I have a test.aspx which populates the hash tables with the data from the database.I have an exe which also instantiates this class to view the refreshed data.I run the aspx first and then run the exe, when the exe is run it says the instance is already present and returns the instance but that instance doesnot have any data in the hash table. My issue is that the singleton is creating a fresh instance or cleaning the data in the hashtable everytime its called from a client could the C# experts throw some light on this.
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks tuck your comment rang a bell i changed my app domain to asp.net and the singleton works like a champ...
Thanks again
Thanks again
beware: if an assembly is unloaded so is your singleton ... asp.net does this from time to time (unload a domain) depending on your setup.
also the use of this causes problems because you force yourself into a single concurrent app pool ... i.e. you can only process 1 concurrent request.
Greg
also the use of this causes problems because you force yourself into a single concurrent app pool ... i.e. you can only process 1 concurrent request.
Greg
A centralized source will be required, there are a few methods of doing this ...
1) Web Service
2) Singleton Remoting
3) File Based Persistance
4) DB Based Persistance
5) Shared Memory Based Persistance
naturally each has its positives and negatives .. could you let us know a bit more about your requirements?
Cheers,
Greg