NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

__pin

Prevents a managed object from being moved by the NGWS runtime.

__pin identifier

Remarks

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.

Example

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;
}

See Also

Managed Extensions for C++ Keywords | C++ Keywords