VB.Net How to implement the singleton pattern for access via WCF
I'd like to expose some functionality via a WCF service. I can configure WCF to instantiate a class per-request but am unsure how I can get a reference to a communal singleton -
If I were to have some functionality to store a list of calls to a method (call it LogMethod) via WCF in memory and return that list when the GetLogs method is called
I'm aware I cou开发者_JAVA百科ld use a database/the file system to pass this data back an forth but in many cases, that seems to be overkill.
Can someone explain how I can use a singleton class (I'm aware it will need to be thread-safe) ?
Many thanks
Edit: It seems that nobody has a clear answer - I can't believe this is complex. Am I missing something obvious?
Your WCF service can simply access any singleton object. For that matter you can (and I have) simply have a Shared
member in your WCF service.
I finally found a WCF article that explains an even better way of implementing this... "Discover Mighty Instance Management Techniques For Developing WCF Apps"
精彩评论