G
Guest
I have a C++/CLI library and I'm calling a function, RegisterTraceGuids()
that takes a function callback as a parm. I need the callback function to be
a managed delegate. In order to do this I create a pin_ptr of the delegate
and then pass it to RegisterTraceGuids.
The problem is that pin_ptr's can only be defined within the scope of a
function, and cant be class members. So once the function that calls
RegisterTraceGuids() is over my pinned delegate gets unpinned. But my
callback could get called at anytime, long after the function goes out of
scope.
So how can I pin a delegate instance for a period longer than the scope of
one function?
that takes a function callback as a parm. I need the callback function to be
a managed delegate. In order to do this I create a pin_ptr of the delegate
and then pass it to RegisterTraceGuids.
The problem is that pin_ptr's can only be defined within the scope of a
function, and cant be class members. So once the function that calls
RegisterTraceGuids() is over my pinned delegate gets unpinned. But my
callback could get called at anytime, long after the function goes out of
scope.
So how can I pin a delegate instance for a period longer than the scope of
one function?