prevent下一个事件处理函数被调用 [英] Prevent next event handler being called

查看:166
本文介绍了prevent下一个事件处理函数被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经连接到一个按钮,单击Windows窗体像这样两个事件处理程序:

I have two event handlers wired up to a button click in a Windows form like so:

this.BtnCreate.Click += new System.EventHandler(new RdlcCreator().FirstHandler);
this.BtnCreate.Click += new System.EventHandler(this.BtnCreate_Click);

两者都被称为正常。

both are being called correctly.

不过,才有可能在 FirstHandler()来prevent BtnCreate_Click()正在执行?是这样的:

However is it possible within FirstHandler() to prevent BtnCreate_Click() being executed? Something like:

void FirstHandler(object sender, EventArgs e)
{
   if (ConditionSatisfied)
     //Prevent next handler in sequence being executed

}

我知道我可以只订阅了事件,但可以这样(的方法内)编程做?

I know I could just unsubscribe the event, but can this be done programmatically (from within the method)?

推荐答案

据我知道有没有办法解决这个。这是因为没有保障,其中,当该事件发生的事件处理程序的调用顺序。

As far as I know there is no solution for this. That's because there is no guarantee for the order in which the event handlers are called when the event happens.

这一点,因为你不应该依赖他们以任何方式顺序。

Because of that you are not supposed to rely on their order in any way.

这篇关于prevent下一个事件处理函数被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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