本文介绍了活动如何进行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
事件引发机制背后是否存在计时器?
我不确定某些事件(例如Click,MouseDown等),但是如果我定义的事件(如零")将在控件的某些属性(支持此事件)的值为0时触发.我认为,此事件的机制是计时器运行并检查该属性的值何时为0,它将触发零"事件.您能告诉我事件引发机制是如何工作的吗?
非常感谢!
Is there a timer behind the event raising mechanism?
I''m not sure about some events like Click, MouseDown, ... But if I have a defined event like "Zero" that will fire whenever some property of a control (supports this event) has 0 as its value. The mechanism for this event, I think, is a timer will run and check whenever the property''s value is 0, it will fire the "Zero" event. Could you please tell me how the event raising mechanism works?
Thank you so much!
推荐答案
// Declare a delegate
public delegate void MyEventHandler(int EventArg);
// Declare the event.
public event MyEventHandler MyEvent;
// Declare an event handler
public void HandleEvent(int EventArg)
{
System.Windows.Forms.MessageBox.Show(EventArg.ToString());
}
protected void Button1_Click(object sender, EventArgs e)
{
// add two handlers... just for fun
MyEvent += HandleEvent;
MyEvent += HandleEvent;
// THIS IS IT! Raise the event
MyEvent(123);
}
这篇关于活动如何进行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!