S
SB
What is the best way to prevent an object from being moved by the garbage
collector (for the lifetime of an application)? Pinning seems to be
designed for temporary operations...so I guess that's not an option.
The reason I'm ask is because I have a class that contains many delegates
that are used as callback functions to a C dll. The dll may call any one of
these delegates at any time...so their addresses must be set in stone until
the app is closed.
I believe I can allocate the object on the stack to prevent it from being
affected by the garbage collector..but I'm not sure if that will work or how
to go about doing it.
Any info would be appreciated!
TIA,
sb
collector (for the lifetime of an application)? Pinning seems to be
designed for temporary operations...so I guess that's not an option.
The reason I'm ask is because I have a class that contains many delegates
that are used as callback functions to a C dll. The dll may call any one of
these delegates at any time...so their addresses must be set in stone until
the app is closed.
I believe I can allocate the object on the stack to prevent it from being
affected by the garbage collector..but I'm not sure if that will work or how
to go about doing it.
Any info would be appreciated!
TIA,
sb