In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to understand the .NET static event chain, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can gain something through the detailed introduction of this article.
In our daily development process, we often encounter the association between multiple class instances, whether it is the project of Bamp S or CMab S, the use of the instance is the same; but the project of Cmax S is relatively easy to control, no matter the objects in the UI layer can be well controlled, including inheritance, rewriting, etc.; but it may not be very convenient in Bhand S.
Because of its own characteristics, we should not expose too many inheritance relationships in order to avoid accidentally breaking the closure of the class. I am mainly discussing how to dynamically associate between multiple class instances, for example, when we develop a Winform project, we may encounter the situation of working together between two or more windows. In this case, I adopt the solution of static event chain, and there is no primary or secondary distinction between multiple instances. Some people will definitely think that defining events in a class, de-instantiating and subscribing to relevant events in the called class; this can not solve the relationship of multi-instance interoperability.
For example, I have five windows distributed in the main interface, and when I click a refresh button in the menu bar, I want to refresh these five windows at the same time, so that all five window instances must subscribe to events from one place; why I use static events is to facilitate the use of multiple instances.
1 、
2:
3:
Figure 3 is the definition of the static event chain class. Defining a static event is a good static method. Notice that I also subscribe to the ClickEvent event in this class, for fear that no instance subscribes to the static event, and then triggers the event, resulting in empty address marshaling failure, that is, null reference call
4:
Figure 4 is an implementation of the simulation window. In the constructor, we subscribe to a ClickEvent event in the static event chain; the other four windows are all the same, so I won't post the picture.
5:
6:
7:
This is the end of the static event chain, and a good way to trigger multiple points through one point is often used in our development process.
The above is how to understand the .NET static event chain. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.