Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / December 2005

Tip: Looking for answers? Try searching our database.

Deterministic Collection Using Generics

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff Louie - 17 Dec 2005 05:55 GMT
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
Brian Gideon - 17 Dec 2005 17:54 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.