Click here to Skip to main content
15,791,846 members
Home / Discussions / C#
   

C#

 
GeneralRe: Thread-Safe Singleton Pin
Heath Stewart8-Dec-03 7:56
protectorHeath Stewart8-Dec-03 7:56 
GeneralRe: Thread-Safe Singleton Pin
Paul Evans8-Dec-03 8:05
Paul Evans8-Dec-03 8:05 
GeneralRe: Thread-Safe Singleton Pin
Heath Stewart8-Dec-03 8:12
protectorHeath Stewart8-Dec-03 8:12 
GeneralRe: Thread-Safe Singleton Pin
Paul Evans8-Dec-03 8:20
Paul Evans8-Dec-03 8:20 
GeneralRe: Thread-Safe Singleton Pin
Heath Stewart8-Dec-03 11:08
protectorHeath Stewart8-Dec-03 11:08 
GeneralRe: Thread-Safe Singleton Pin
bzurer8-Dec-03 8:07
bzurer8-Dec-03 8:07 
GeneralRe: Thread-Safe Singleton Pin
Heath Stewart8-Dec-03 8:10
protectorHeath Stewart8-Dec-03 8:10 
GeneralRe: Thread-Safe Singleton Pin
bzurer8-Dec-03 8:56
bzurer8-Dec-03 8:56 
In this case, my Singleton will be used to synchronize access to a centralized Hashtable which holds the 'clean' or saved values of properties of objects while the actual objects are being validated, persisted and then finally updated if all goes well. After the update succeeds the values are removed from the hash table.

The aim is to allow multiple threads to be able to have read consistency while a write is going on. I want to accomplish this by deriving all my business from ContextBoundObject.All calls to set methods would be intercepted and the existing values added to this Hashtable(keyed to a global object id).

When another thread wants to read, the get method is intercepted, and, in SyncProcessMessage, the MessageSink checks for an entry in this Hashtable, if one is found, the value of the property is taken from the Hashtable and passed to the caller, otherwise it passes the IMessage unaltered.

I assume this Hashtable qualifies as a resource.

But this brings up another two questions.

1 - By using ContextBoundObject am I in some way automatically serializing access? and if not
2 - Must I place a lock within SyncProcessMessage?



GeneralRe: Thread-Safe Singleton Pin
Heath Stewart8-Dec-03 10:14
protectorHeath Stewart8-Dec-03 10:14 
GeneralRe: Thread-Safe Singleton Pin
Zhang Ye Fan8-Dec-03 8:33
Zhang Ye Fan8-Dec-03 8:33 
GeneralRe: Thread-Safe Singleton Pin
Heath Stewart8-Dec-03 10:08
protectorHeath Stewart8-Dec-03 10:08 
GeneralRe: Thread-Safe Singleton Pin
bzurer11-Dec-03 4:31
bzurer11-Dec-03 4:31 
GeneralRe: Thread-Safe Singleton Pin
Heath Stewart11-Dec-03 5:30
protectorHeath Stewart11-Dec-03 5:30 
GeneralRe: Thread-Safe Singleton Pin
bzurer11-Dec-03 5:56
bzurer11-Dec-03 5:56 
Generalabout setup projects Pin
Mauricio Ritter8-Dec-03 4:50
Mauricio Ritter8-Dec-03 4:50 
GeneralRe: about setup projects Pin
Heath Stewart8-Dec-03 4:55
protectorHeath Stewart8-Dec-03 4:55 
GeneralRe: about setup projects Pin
Mauricio Ritter8-Dec-03 5:20
Mauricio Ritter8-Dec-03 5:20 
GeneralRe: about setup projects Pin
Heath Stewart8-Dec-03 5:52
protectorHeath Stewart8-Dec-03 5:52 
QuestionAbout Collections? Pin
E#8-Dec-03 4:29
sussE#8-Dec-03 4:29 
AnswerRe: About Collections? Pin
E#8-Dec-03 4:31
sussE#8-Dec-03 4:31 
AnswerRe: About Collections? Pin
Heath Stewart8-Dec-03 4:52
protectorHeath Stewart8-Dec-03 4:52 
GeneralRe: About Collections? Pin
leppie8-Dec-03 7:19
leppie8-Dec-03 7:19 
GeneralRe: About Collections? Pin
Heath Stewart8-Dec-03 7:22
protectorHeath Stewart8-Dec-03 7:22 
QuestionOR? Pin
eggie58-Dec-03 4:22
eggie58-Dec-03 4:22 
AnswerRe: OR? Pin
Heath Stewart8-Dec-03 4:47
protectorHeath Stewart8-Dec-03 4:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.