RE: reference to handle / handle to reference
From: Chris Lyon [MSFT] (clyon_at_online.microsoft.com)
Date: 01/14/05
- Next message: [Alan Flores]: "Re: Javascript before all postback"
- Previous message: C.E.O. Gargantua: "Re: DB2 IBM OleDB Provider"
- In reply to: Christian Lammel: "reference to handle / handle to reference"
- Next in thread: Mattias Sjögren: "Re: reference to handle / handle to reference"
- Reply: Mattias Sjögren: "Re: reference to handle / handle to reference"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 14 Jan 2005 20:27:52 GMT
As far as I know, there's no conversion between an object reference and an Int32, unless you pin objects using GCHandles and get their associated IntPtrs.
Also, if you're storing references in a Hashtable, then you are affecting the garbage collector by holding references to the objects, so they'll never get collected.
Even if references are stored internally as numbers in a GC table, there's no way for managed code to access it.
Hope that helps
-Chris
--------------------
>
>i'm looking for a possibility in C# to get a unique Int32 handle for an
>object reference. This handle must later (within the same process of course)
>be convertible back to an object reference (call it handle or pointer or
>whatever...).
>at the moment i'm working with a Hashtable Int32 to Object, but i want to
>optimize this. I know it is possible to work with pointers in unsafe code
>blocks, but as far as i know these pointer remain valid only within these
>blocks, or when they are pinned. and i don't want to disturb the garbage
>collector.
>i mean, somehow a reference must be a number anyway, perhaps an index within
>some garbage collector table, or am i wrong?
>
>
-- This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
- Next message: [Alan Flores]: "Re: Javascript before all postback"
- Previous message: C.E.O. Gargantua: "Re: DB2 IBM OleDB Provider"
- In reply to: Christian Lammel: "reference to handle / handle to reference"
- Next in thread: Mattias Sjögren: "Re: reference to handle / handle to reference"
- Reply: Mattias Sjögren: "Re: reference to handle / handle to reference"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|