强制事件监听器 [英] Force an event listener

查看:109
本文介绍了强制事件监听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法强迫我的对象的消费者处理我被解雇的事件?
?我不在乎他们如何处理这个事件,只是他们这样做了。我认为在c#中有一种方法但不确定vb.net。

请指教。

解决方案

< blockquote> ee******@gmail.com 在新闻中写道:1184334865.640320.11950

@ o61g2000hsh.googlegroups.com:


有没有办法强迫我的对象的消费者处理事件

我是被解雇了?我不在乎他们如何处理这个事件,只是他们这样做了。我认为在c#中有一种方法但不确定vb.net。

请指教。



AddHandler允许您为事件分配事件处理程序。


7月13日上午10点23分, Spam Catcher< spamhoney ... @ rogers.comwrote:


eedar ... @ gmail.com在新闻中写道:1184334865.640320.11950

@ o61g2000hsh.googlegroups.com:


有没有办法强迫我的对象的消费者处理事件

我是被解雇了?我不在乎他们如何处理这个事件,只是他们这样做了。我认为在c#中有一种方法但不确定vb.net。

请指教。



AddHandler允许您为函数分配事件处理程序。



感谢您的回复,但我所追求的不是如何处理

事件,而是确保消费者在处理我的事件的事实。所以我的对象中有
,在关闭事件之前,我想查看是否确实消费者实际上已经添加了一个事件处理程序。




问候


ee * *****@gmail.com 在新闻中写道:1184336972.552129.89600

@ o61g2000hsh.googlegroups.com:


感谢您的回复,但我所追求的并不是如何处理

事件,而是确保消费者实际上正在处理我的事件。所以我的对象中的
,在关闭事件之前,我想检查一下,看看是否实际上消费者已经添加了一个事件处理程序。



最好的方法是使用插件系统。


创建一个界面并确保任何类需要收听你的

事件实现界面。


你的加载器类会将事件绑定到正确的事件处理程序。

这将确保:


1.所有必需的处理程序都已实现

2.您的加载程序类将所有事件附加到正确的处理程序


Is there a way to force the consumer of my object to handle events
that I''ve fired off? I don''t care how they handle the event, just that
they do. I think in c# there is a way but not sure about vb.net.
Please advise.

解决方案

ee******@gmail.com wrote in news:1184334865.640320.11950
@o61g2000hsh.googlegroups.com:

Is there a way to force the consumer of my object to handle events
that I''ve fired off? I don''t care how they handle the event, just that
they do. I think in c# there is a way but not sure about vb.net.
Please advise.

AddHandler allows you to assign event handlers to functions.


On Jul 13, 10:23 am, Spam Catcher <spamhoney...@rogers.comwrote:

eedar...@gmail.com wrote in news:1184334865.640320.11950
@o61g2000hsh.googlegroups.com:

Is there a way to force the consumer of my object to handle events
that I''ve fired off? I don''t care how they handle the event, just that
they do. I think in c# there is a way but not sure about vb.net.
Please advise.


AddHandler allows you to assign event handlers to functions.

Thanks for the response, But what I''m after is not how to handle an
event but ensuring that the consumer is in fact handling my events. So
in my object, before firing off the event, I want to check and see if
in fact the consumer has in fact added an event handler.

Regards


ee******@gmail.com wrote in news:1184336972.552129.89600
@o61g2000hsh.googlegroups.com:

Thanks for the response, But what I''m after is not how to handle an
event but ensuring that the consumer is in fact handling my events. So
in my object, before firing off the event, I want to check and see if
in fact the consumer has in fact added an event handler.

The best way to do this is with a plug-in system.

Create an interface and insure any classes that need to listen to your
events implement the interface.

Your loader class will bind the events to the proper event handlers.

This will ensure:

1. All required handlers are implemented
2. Your loader class attaches all the events to the proper handlers


这篇关于强制事件监听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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