本文介绍了DllImport,回调和垃圾收集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。


我正在努力使这项工作,但我有一个奇怪的行为。我有一个非常好的b $ b基本系统,我称之为非管理型dllimported。函数并给它一个

的回调函数结构。


有时,非托管部分会调用其中一个回调函数。但是

第一个指针的指针从地址变为0x00000001。

我无法弄明白为什么。


我的想法是收集垃圾,但我不明白为什么(我尝试了不同的方式,我目前使用结构实例作为静态)。另外

为什么垃圾收集器会把它设置为1而不是0?


任何链接或帮助将不胜感激:)


代码:

推荐答案






我不确定它是否会起作用,固定"只能用很短的时间

时间,我的回调会一直调用,直到程序退出。

另外,新地址是0x00000001。我宁愿怀疑垃圾

收集物品的移动。



I am not sure it would work, "fixed" can only be used for a short amount
of time, my callbacks are called all the time until the program exits.
Also as the new address is "0x00000001" I would rather suspect a garbage
collecting that a move of the object.




我不确定它会起作用,修复只能在短时间内使用,我的回调会一直调用,直到程序退出。
另外,因为新地址是0x00000001。我宁愿怀疑垃圾收集对象的移动。



I am not sure it would work, "fixed" can only be used for a short amount
of time, my callbacks are called all the time until the program exits.
Also as the new address is "0x00000001" I would rather suspect a garbage
collecting that a move of the object.



这篇关于DllImport,回调和垃圾收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 06:48