Skip to content

Commit bad92b3

Browse files
authored
Update how-to-marshal-callbacks-and-delegates-by-using-cpp-interop.md
typo: underlaying -> underlying
1 parent 70fbbb5 commit bad92b3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/dotnet/how-to-marshal-callbacks-and-delegates-by-using-cpp-interop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The following example demonstrates how to configure an unmanaged API to trigger
1818

1919
Notice that is it possible, but not necessary, to pin the delegate using [pin_ptr (C++/CLI)](../extensions/pin-ptr-cpp-cli.md) to prevent it from being re-located or disposed of by the garbage collector. Protection from premature garbage collection is needed, but pinning provides more protection than is necessary, as it prevents collection but also prevents relocation.
2020

21-
If a delegate is re-located by a garbage collection, it will not affect the underlaying managed callback, so <xref:System.Runtime.InteropServices.GCHandle.Alloc%2A> is used to add a reference to the delegate, allowing relocation of the delegate, but preventing disposal. Using GCHandle instead of pin_ptr reduces fragmentation potential of the managed heap.
21+
If a delegate is re-located by a garbage collection, it will not affect the underlying managed callback, so <xref:System.Runtime.InteropServices.GCHandle.Alloc%2A> is used to add a reference to the delegate, allowing relocation of the delegate, but preventing disposal. Using GCHandle instead of pin_ptr reduces fragmentation potential of the managed heap.
2222

2323
```cpp
2424
// MarshalDelegate1.cpp

0 commit comments

Comments
 (0)