Prevents a managed object from being moved by the NGWS runtime.
__pin identifier
The __pin keyword prevents the NGWS runtime from moving a local variable during garbage collection. This is useful when passing the address of a managed variable to an unmanaged function because the address does not change unexpectedly during resolution of the external function call.
In the following example, the object pointed to by pG
is pinned until it passes out of scope:
#using <mscorlib.dll> #using namespace System; __gc class G { public: int i; }; void GenericFunc(G* pG) { G __pin* ppG = pG; }
Managed Extensions for C++ Keywords | C++ Keywords