Creating a HANDLE[] in a managed class

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I've created a HANDLE[] in a managed class:

pHandle = new HANDLE[2];

where pHandle is HANDLE* defined in my __gc class

Is this an unamanged or a managed pointer? I would have thought it would be
unmanaged but I can __pin it, which implies it is managed.

Help appreciated.

Thanks

Jon
 
Jon,
I've created a HANDLE[] in a managed class:

pHandle = new HANDLE[2];

where pHandle is HANDLE* defined in my __gc class

Is this an unamanged or a managed pointer? I would have thought it would be
unmanaged but I can __pin it, which implies it is managed.

That depends on how you look at it:
The memory referenced by pHandle is *unmanaged*, since it is stored in the
CRT heap. However, the memory pHandle itself is stored is actually in the GC
heap, since it is part of a reference object.

If you needed to pass &pHandle to an unmanaged function, then you'd
certainly need to pin it first...
 
Thanks Tomas

.......question answered perfectly. The light is now on!

Jon

Tomas Restrepo (MVP) said:
Jon,
I've created a HANDLE[] in a managed class:

pHandle = new HANDLE[2];

where pHandle is HANDLE* defined in my __gc class

Is this an unamanged or a managed pointer? I would have thought it would be
unmanaged but I can __pin it, which implies it is managed.

That depends on how you look at it:
The memory referenced by pHandle is *unmanaged*, since it is stored in the
CRT heap. However, the memory pHandle itself is stored is actually in the GC
heap, since it is part of a reference object.

If you needed to pass &pHandle to an unmanaged function, then you'd
certainly need to pin it first...
 
Back
Top