Pinning an updateble struct before passing to unmanaged code?

后端 未结 6 2069
一个人的身影
一个人的身影 2021-02-04 11:11

I using some old API and need to pass the a pointer of a struct to unmanaged code that runs asynchronous.

In other words, after i passing the struct pointer to the unman

6条回答
  •  故里飘歌
    2021-02-04 12:06

    Instead of pinning, you need to use Marshal.StructureToPtr and Marshal.PtrToStructure to marshal the struct into memory that's usable in native code.

提交回复
热议问题