----- Original Message ----- From: "Ron O'Rourke" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, September 12, 2003 4:24 PM Subject: Re: [ADVANCED-DOTNET] Object identities, marshaling issues and interoperability
> Per the Hashtable Class docs: > > "The objects used as keys in a Hashtable must implement or inherit the > Object.GetHashCode and Object.Equals methods. If key equality were simply > reference equality, the inherited implementation of these methods would > suffice. Furthermore, these methods must produce the same results when > called with the same parameters while the key exists in the Hashtable. Key > objects must be immutable as long as they are used as keys in the > Hashtable." > > Assuming you have the ability to modify the Item code, override the default > implementation of GetHashCode and Equals to provide/use a unique key. If > Item isn't changable or providing a default implementation of Equals would > break too much, you could consider a wrapper class for the Item objects. > The wrapper class would be stored in the Hashtable instead. I can't change Item implementation. Well, when I was talking about some information in the Hashtable, this information was really a wrapper around Items, and the Hashtable contains mapping from Items to corresponding wrappers. Even having Items wrapped, I still sometimes need to get the wrapper for an Item. In particular, this happens when the UI thread receives an event from the external component and the event contains an Item as an argument. The UI thread hence accesses the hashtable to get the wrapper, and the problem arises. > > On Fri, 12 Sep 2003 13:25:27 +0400, Dmitry Shaporenkov wrote: > > >Hi all, > > <Snip> > > >However, I need a way to identify items in a thread-independent fashion. > >Items themselves do not have any properties which might serve as a reliable > >unique identifiers. > > <Snip> > > >Any advices / references will be greatly appreciated. Thanks in advance. > > > >Regards, > >Dmitry Shaporenkov > > =================================== > This list is hosted by DevelopMentor╝ http://www.develop.com > NEW! ASP.NET courses you may be interested in: > > 2 Days of ASP.NET, 29 Sept 2003, in Redmond > http://www.develop.com/courses/2daspdotnet > > Guerrilla ASP.NET, 13 Oct 2003, in Boston > http://www.develop.com/courses/gaspdotnet > > View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor╝ http://www.develop.com NEW! ASP.NET courses you may be interested in: 2 Days of ASP.NET, 29 Sept 2003, in Redmond http://www.develop.com/courses/2daspdotnet Guerrilla ASP.NET, 13 Oct 2003, in Boston http://www.develop.com/courses/gaspdotnet View archives and manage your subscription(s) at http://discuss.develop.com