Here is my try at generics. This creates a collection that implements
IInvoke and IDisposable and Adds types that implement IInvoke and
IDisposable. When the collection goes out of using scope dispose is
called on all members of the collection. Calling Invoke on the
collection calls Invoke on each member of the collection.
http://www.geocities.com/jeff_louie/oop29.htm
Regards,
Jeff
Jeff,
It appears the JALGenericCollection<T> and JALCollection objects were
intended to be thread-safe, but they're not quite there yet. The
problem is with the Dispose method and the checks at the beginning of
Add, Clear, and Invoke to see if the object has been disposed.
Synchronization has not be applied correctly to prevent one thread from
calling Dispose while another calls Invoke after the object has been
disposed.
Aren't generics a great addition to the language?
Brian
> Here is my try at generics. This creates a collection that implements
> IInvoke and IDisposable and Adds types that implement IInvoke and
[quoted text clipped - 8 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***
Jeff Louie - 18 Dec 2005 06:38 GMT
Brian...Thanks for the tip. My old brain is having trouble learning
thread safety. I moved the disposed clause inside the locks. Does this
look correct now?
http://www.geocities.com/jeff_louie/oop29.htm
You may need to refresh the page load. And yes, Generics are cool.
Regards,
Jeff
>It appears the JALGenericCollection<T> and JALCollection objects were
intended to be thread-safe, but they're not quite there yet. The problem
is with the Dispose method and the checks at the beginning of Add,
Clear, and Invoke to see if the object has been disposed.
Synchronization has not be applied correctly to prevent one thread from
calling Dispose while another calls Invoke after the object has been
disposed.
Aren't generics a great addition to the language?<
Brian Gideon - 18 Dec 2005 14:23 GMT
> Brian...Thanks for the tip. My old brain is having trouble learning
> thread safety. I moved the disposed clause inside the locks. Does this
> look correct now?
>
> http://www.geocities.com/jeff_louie/oop29.htm
It looks correct now. Thread-safety is tricky to get right.
Brian