开发者

Finalizing a COM object

I'm trying to implement a sing开发者_开发技巧leton class, that holds a com object inside it. Class implements IDisposable interface, but when I try to implement a finalization method, I get an exception of access to com object from another thread.

This happens because clr uses a different thread when finalizes objects.

Is there any way to implement such a thing or maybe I just doing something wrong?


You only need to implement a finalizer if the class diectly manages the non-managed resource. A COM object is wrapped in a RCW (runtime callable wrapper), so there is already a managed type between your type and the COM interface pointer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜