自动为COM对象生成的包装器可以处理所有事件! [英] Automatically generated wrapper for COM object handles all events!

查看:74
本文介绍了自动为COM对象生成的包装器可以处理所有事件!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我有一个COM对象,并在我的应用程序中使用它.

I have a COM-object, and use it in my app.

COM对象引发许多事件,而我的应用订阅了其中一些事件.

COM object raises many events and my app subscribed on some of this events.

创建此COM对象时,我的应用程序将处理器加载到50%.

When I create this COM-object, my app loads the processor on 50%.

我使用事件探查器对其进行了跟踪,发现处理器已由加载 处理我未订阅的事件!

I'm traced it with profiler and found that the processor is loaded by processing of events on which I didn't subscribe!

比我得出的结论是,.NET处理COM对象的所有事件,如果我的应用已订阅,则会引发我的处理程序.

Than I make a conclusion that .NET processes all events of COM object, and if my app is subscribed - raises my handlers.

如何禁用所有事件的订阅?或者如何在没有我不想处理的事件的情况下生成Interop dll?

How I can disable subscribing on all events?? Or how I can generate Interop dll without events that i don't want to process?

推荐答案

您可以编写自己的包装器类COM对象,将仅进行所需的API调用并订阅/引发事件.

You can write your own wrapper class over COM object which will make only API calls that are needed and also subscribe/raise events.

在此示例中将执行相同操作.

Here is in example to do the same.

call-unmanaged-code


这篇关于自动为COM对象生成的包装器可以处理所有事件!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆