开发者

Can a com server object written in C# discover immediately when the client releases it?

The object can know when its client creates it because the constructor runs.

But since C# does not have deterministic destructors, Dispose or Finalize isn't called until the GC, eventually, cleans up the object.

Is there a way a server object can promptly di开发者_如何学Cscover that its client has released it? I don't need the object released at this point, just a method called.

Thanks, ++PLS


No, the CCW (COM Callable Wrapper) sits in between. It merely drops the reference to the managed object when the reference count reaches zero so that object can eventually be collected. You can't wire into the CCW, it is opaque and doesn't generate any events.


the purpose of Dispose is to make object destruction deterministic rather waiting for GC to call finalizer. anyways you can call Marshal.ReleaseComObject to decrement the reference count on the COM object.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜