WinForms中的按钮有一个CLICK事件。(The Button in WinForms has a CLICK event. But who tells the Button object that it has been clicked?)
我正在学习C#。 我正在浏览该语言的事件和代表部分。 我正在开发一个用于教育自己的WinForms应用程序。 我试图深入了解Buttons以及它们是如何工作的。 我发现以下内容:
1)在我的默认Form1.cs文件中有一行
public partial class Form1 : Form
。 这是一个部分课程。2)我也有一个Form1.Designer.cs类文件,它具有一个行部
partial class Form1
。 现在1)和2)中提到的文件组合起来形成一个完整的课程。3)From1.Designer.cs文件有很多最终创建按钮对象的语句。 它还有一个我特别感兴趣的声明:
this.btn_BaseBuildLocation.Click += new System.EventHandler(this.btn_BaseBuildLocation_Click);
此语句将自定义函数添加到委托单击。 该委托在Control类(System.Windows.Forms.dll)中声明如下:
public event EventHandler Click;
4)EventHandler是在System.EventHandler.cs(mscorlib.dll)中定义的委托。
5)Button类继承Control类,因此可以访问Click EventHandler。
6)一旦知道某人点击了它,Button类就具有处理该流的所有逻辑。 我查看了Mono中用于了解内部细节的Button类。 我为几乎所有我想学习的课程都这样做。
7)所有这些都非常漂亮。 但是我很困惑,因为我不知道Button对象是如何知道它已被点击的。
8)我经历了VC ++以及它如何处理事件。 我发现很多关于消息循环,事件队列等等......
问题:
1)处理事件的VC ++方式是否与.NET相同?
2)如果是这样,有没有办法查看这些细节?
任何帮助,将不胜感激。 谢谢。
I am learning C#. I was going through the Events and Delegates part of the language. I am working on a WinForms application for educating myself. I tried looking deep for understanding Buttons and how they work. I found the following:
1) There is a line
public partial class Form1 : Form
in my default Form1.cs file. This is a partial class.2) I also have a Form1.Designer.cs class file that has a line
partial class Form1
. Now the files mentioned in 1) and 2) combine to form a full class.3) The From1.Designer.cs file has a lot of statements that eventually create the button object. It also has a statement that is of particular interest to me:
this.btn_BaseBuildLocation.Click += new System.EventHandler(this.btn_BaseBuildLocation_Click);
This statement adds a custom function to the delegate Click. This delegate is declared in the Control class (System.Windows.Forms.dll) as follows:
public event EventHandler Click;
4) The EventHandler is a delegate defined in System.EventHandler.cs (mscorlib.dll).
5) The Button class inherits Control class and thus has access to the Click EventHandler.
6) The Button class has all the logic to handle the flow once it knows that someone has clicked it. I had a look at the Button class used in Mono for understanding the inner details. I do this for almost all classes that I want to learn.
7) All this is extremely beautiful. But I was troubled by the fact that I did not know how the Button object knows that it has been clicked.
8) I went through VC++ and how it handles the events. I found a lot about Message Loops, Event Queues etc...
Questions:
1) Is the VC++ way of handling events the same as .NET's?
2) If so, is there a way to look into those details?
Any help would be appreciated. Thanks.
原文:https://stackoverflow.com/questions/17649233
最满意答案
MSBuild没有新版本,您仍然使用4.5
There is no new version of MSBuild, you still use 4.5
相关问答
更多-
是否有可能使PhpStorm 10.0支持PHP 7.1 没有。 还是我需要升级到新版本? 是。 您至少需要2016.2.2才能支持此类语法(目前最新版本为2017.2.1)。 https://stackoverflow.com/a/45483094/783119 Is it possible to make PhpStorm 10.0 php 7.1-aware No. or do I need to upgrade to the new version? Yes. You need at very le ...
-
应用程序池版本4是否支持.net Framework 4.5.1?(Does application pool version 4 support .net Framework 4.5.1?)[2023-04-29]
版本4.0.30319.17626表示.NET 4.5 RC,您可以在版本表中看到。 然而,.NET 4.5.1以4.0.30319.18408开头。 Version 4.0.30319.17626 means .NET 4.5 RC, as you could see in the table of versions. .NET 4.5.1 starts with 4.0.30319.18408 however. -
Teamcity代理自动检测现有配置属性。 根据Teamcity的文档PredefinedBuildParameters-AgentProperties : TeamCity自动检测许多应用程序,包括.NET Framework,Visual Studio的存在,并添加相应的系统属性和环境变量 在同一页面的表格中,它显示: WindowsSDK如果安装了相应版本的Windows SDK,则会定义此属性。 (支持的版本是6.0,6.0A,7.0,7.0A,7.1) 因此,请尝试重新启动Teamcity代理,以 ...
-
JBoss 7.1支持状态?(JBoss 7.1 support status?)[2022-07-05]
RedHat不支持JBoss 7.1.1 AS(AS产品现已重命名为Wildfly,它基本上是JBoss的免费版本)。 是的,你可以说它是JBoss的“社区版”。 支持JBoss 7 EAP等EAP产品,但它们是商业性的,您必须为其使用和支持支付订阅费。 Redhat通常将错误修正等从其商业版本反向到AS产品,但这并不保证,并且在后者的情况下没有固定的支持周期或维护阶段。 JBoss 7.1.1 AS isn't supported by RedHat (AS products have now been ... -
ASP.NET Core BundlerMinifier.Core是否支持.net 4.5.1?(Does ASP.NET Core BundlerMinifier.Core support .net 4.5.1?)[2023-07-07]
如果你查看BundlerMinifier.Core project.json文件,你会发现只有"netcoreapp1.0"和"net452" ,所以现在答案是“不”。 如果您可以将项目升级到.NET 4.5.2,应该可以工作 If you look into BundlerMinifier.Core project.json file, you will find only "netcoreapp1.0" and "net452", so right now the answer is "no". Sho ... -
有没有办法为Teamcity 7.1添加.net 4.5.1支持?(Is there any way to add .net 4.5.1 support to Teamcity 7.1?)[2023-05-30]
MSBuild没有新版本,您仍然使用4.5 There is no new version of MSBuild, you still use 4.5 -
还尝试添加对以下内容的引用: System.Threading.dll System.Threading.Tasks.dll Try also to add a reference to: System.Threading.dll System.Threading.Tasks.dll
-
Team City上的.Net 4.5.1(.Net 4.5.1 on Team City)[2022-04-12]
当通过rake使用msbuild任务时,我遇到了类似的问题: http : //www.beta.microsoft.com/VisualStudio/feedback/details/806393/error-trying-to-build-using-msbuild-from-code 您好,感谢您的反馈。 我相信你遇到这个问题是因为MSBuild移出.NET Framework的副作用(更多信息请访问: http : //blogs.msdn.com/b/visualstudio/archive/20 ... -
您将在Micorosft ASP.NET Web API 2.1 Client NuGet包中找到PostAsJsonAsync扩展方法。 然而,如果你适当地设置HttpContent , PostAsync方法应该工作。 在这个讨论中可以找到一个例子。 You will find the PostAsJsonAsync extension method in the Micorosft ASP.NET Web API 2.1 Client NuGet package. Nevertheless, if y ...
-
是的,请查看MSDN上的这篇文章 : .NET Framework 4.5.1是对.NET Framework 4.5的就地更新。 .NET Framework 4.5和.NET Framework 4.5.1替换.NET Framework 4.在安装了.NET Framework 4的系统上安装这些版本时,将替换程序集。 It is, check this article at MSDN: The .NET Framework 4.5.1 is an in-place update to the .NE ...