如何在该事件的另一个实例被触发之前完成一个事件C# [英] How to complete a event before another instance of that event gets fired C#

查看:50
本文介绍了如何在该事件的另一个实例被触发之前完成一个事件C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在点击事件被触发时执行特定操作。

如果用户在现有事件完成后连续点击该按钮控件,则会调用新事件。因此我的操作失败了。



我试图保留一个标志来执行此操作但是一旦标志被激活,新实例就会被激活。



有没有办法解决这个问题。

I am performing a particular operation when a click event is fired.
If a user continuously clicks that button control as soon as the existing event finishes the new event gets called. Hence my operation fails.

I tried keeping a flag to do this but as soon the flag gets activated the new instance gets activated.

Is there any way to solve this.

推荐答案

您可以在事件处理程序的最开头禁用该按钮并再次启用它操作完成后。
You could disable the button at the very beginning of the event handler and enable it again when the operation is completed.


这篇关于如何在该事件的另一个实例被触发之前完成一个事件C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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