[英]c# Prevent try icon MouseDoubleClick event multiple times
How can i prevent try icon MouseDoubleClick event while running a method? 如何在运行方法时阻止尝试图标MouseDoubleClick事件? Because when i double click try icon while running a method, mouse click events queuing and than executing the method again when it ends. 因为当我在运行方法时双击尝试图标时,鼠标单击事件排队,而不是在结束时再次执行该方法。 Try icon does not have disable property. 尝试图标没有禁用属性。 So i tried putting following event handlers at the beginning and end of the method but did not work. 所以我尝试在方法的开头和结尾放置以下事件处理程序但是没有用。
//Begining;
tryicon.MouseDoubleClick -= new MouseEventHandler(tryicon_MouseDoubleClick);
//End;
tryicon.MouseDoubleClick += new MouseEventHandler(tryicon_MouseDoubleClick);
And i also tried; 我也尝试过;
private bool IsExecuted = false;
//Method Beginnig
IsExecuted = true;
//Method End
IsExecuted = false;
//MouseDoubleClickEvent
if(IsExecuted == false)
{
Method();
}
else
{
MessageBox("Already Running")
}
Thanks for your help... 谢谢你的帮助...
You can use PreviewMouseLeftButtonDown
Event and check following condition in the event block 您可以使用PreviewMouseLeftButtonDown
事件并在事件块中检查以下条件
if(e.ClickCount > 1 )
{
e.Handle = true;
return;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.