使用C#怀疑事件处理程序 [英] Doubt in event handlers using C#
本文介绍了使用C#怀疑事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我应该在我的项目中处理一个事件(C#,Visual Studio).
有两个与表单相关的文件.两个文件中都有key_down事件.
我该如何确定首先调用哪个文件的事件.
我猜测一个事件永远不会被调用.
帮助我解决此问题.
Hi all,
I am supposed to handle an event in my project (c#,, visual studio ).
There are two files related to a form. there is key_down event in both the files.
How can i make out that which file''s event is called first.
I have a guess that in one file the events is never called.
Help me out to solve this issue.
推荐答案
使用Visual Studio调试器?怎么说?
Using Visual Studio DEBUGGER? What say?
Sandeep是正确的.只需在两个处理程序中都设置一个断点,在调试模式下运行您的应用程序,敲一个键,看看您首先在哪里停止.
通常,应按分配的相同顺序调用处理程序:
Sandeep is right. Just put a break point into both handlers, run your app in debug mode, hit a key and see where you stop first.
Normally, your handlers should be called in the same order of the assignements:
...
{
//first assignement
MyEvent += MyEventHandler1;
//Second assignement
MyEvent += MyEventHandler2;
}
void MyEventHandler1(object sender, EventArgs e)
{
//will be called first
}
void MyEventHandler2(object sender, EventArgs e)
{
//will be called after
}
这篇关于使用C#怀疑事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文