954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

thread safe observer pattern

Hi

I have a static collection class being observed by a number of observers. The objects in the collection are updated when events occur in a 3rd party application and to which the class subscribes.

I inform the observers about any changes to the collection, or objects within the collection, by raising an event and passing the object that has changed.

I can see that I may run into threading issues with this approach because observers and the 3rd party application all have access to the same object reference.

I would be grateful for advice on how to make this pattern thread safe. Is passing the object whose properties have changed a bad idea? What would be the correct way of doing this?

Many thanks

icgc
Newbie Poster
3 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: