0
Answer

Limited period Singleton in C#

v.simi

v.simi

20y
1.3k
1
Hi, I want to implement a class in C#, such that one instance of that object should be alive if there are threads using it. If no thread is using it, then delete the object. So that the next time, any thread needs this class, it should again be created. It could have been classic singleton, if it would have been alive throughout. But the hitch is that i need to kill/delete the object when i determine that there is nobody else using it... Is Locks/mutex is the way out along with reference count. Could some body throw some light..