如何检查事件是否已加载? [英] How to check if event is loaded?

查看:72
本文介绍了如何检查事件是否已加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用DataGrid并已分配


this.DataSourceChanged + = new EventHandler(DataGrid_DataSourceChanged

);


这样可行,但有一种情况不行。我怎样才能检查DataSourceChanged是否分配了任何东西。我可以将它添加到

手表,因为它说它需要位于 - =或+ =的左侧。


谢谢,

Brett

I''m using a DataGrid and have assigned

this.DataSourceChanged += new EventHandler( DataGrid_DataSourceChanged
);

This works fine but there is one case where it doesn''t. How can I
check if DataSourceChanged has anything assigned. I can add it to the
watch because it says it needs to be on the left side of a -= or +=.

Thanks,
Brett

推荐答案

除非你拥有公共事件的类,没有强大的

方式这样做。但是,如果你已经订阅了这个事件(并且它没有错误),那么很可能它工作正常并且

DataSourceChanged支持者(至少) 1名代表。


你能否提供一些不起作用的案例?它更可能是特定于您的使用/期望。


Marc

Unless you "own" the class publichsing the event, there is no robust
way of doing this. However, if you have subscribed to the event (and it
didn''t error) then chances are that it worked fine and the
DataSourceChanged backer has (at least) 1 delegate.

Can you give any more details on the one case where it doesn''t work? It
is more likely to be specific to your usage / expectations.

Marc


除非你拥有公共活动的课程


你自己上课的意思是什么?我已经创建了所有涉及的代码。


事件在一个案例中没有触发。我知道因为

中的断点,委托方法永远不会在一个案例中被击中。我想提供

的详细信息,但这需要大量的解释。如果只有一个

的方式来检查一个事件的调用列表,那将是一个好的开始。


谢谢,

Brett

Unless you "own" the class publichsing the event

What do you mean by own the class? I''ve created all the code involved.

The event isn''t firing in the one case. I know because a breakpoint in
the delegated method is never hit in the one case. I''d like to give
details but it would require lots of explaining. If there is just a
way to check the invocation list for the one event, that would be a
good start.

Thanks,
Brett


我的意思是DataGrid,所以没有:你不是。不,没有。

I mean DataGrid, so no: you don''t. And no there isn''t.


这篇关于如何检查事件是否已加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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