当前位置:网站首页>【 temperature warning program DE development 】 event driven model instance
【 temperature warning program DE development 】 event driven model instance
2022-08-05 10:03:00 【51CTO】
写在开头:
文章目录
- 一.Define information related classes and events alarm
- 1.1The first step in the declaration delegate type
- 1.2The second step custom event alarm:
- 1.2.1Declare our delegate type
- 1.2.2声明事件
- 1.2.3Starting to monitor the temperature,同时发布事件
- 1.2.4Methods that need the statement event
- 二.事件调用
- 2.1In the receiver class to subscribe to events
- 2.2Trigger button to start the timer
- 三.效果图展示
- 3.1图示
- 3.2代码
- 3.3代码下载地址
一.Define information related classes and events alarm
Why do you want to talk about delegate type?Can entrust is a kind of dynamic method is called type,属于引用型.C#Implementing event-driven programming model is the main way is to use method to realize the dynamic invocation delegate type.
Before we always through a pointer or object variable access memory address,But now we need to use delegate object references memory address to realize transmission and call.
1.1The first step in the declaration delegate type
我们自己定义了一个事件数据类型:TemperatureEventArgs
,It is us to define a类,We sealed inside we need数据信息.
Our class name is our事件数据类型,它同样具有类的所有特性,Such as the definition method to construct,方法,The property and so on.We define the events数据类型为TemperatureEventArgs
,它是从EventArgs
Are derived from.它的目的就是:
To provide all the fields need to preserve the event data or attribute,Such event publisher specific data can be sent to the receiver.
1.2The second step custom event alarm:
1.2.1Declare our delegate type
Statement format is:
public delegate 返回值类型 委托类型名(object sender,事件数据类型 e);
code:
We entrust type name is custom yo!
1.2.2声明事件
Statement format is:
public event 委托类型名 事件名;
PS: The event name best withOn_
Beginning more spec!
1.2.3Starting to monitor the temperature,同时发布事件
1.2.4Methods that need the statement event
二.事件调用
写上代码:
2.1In the receiver class to subscribe to events
Good statement before you subscribe to our object
2.2Trigger button to start the timer
We set up our firsttimmer,Adjust the time interval1000s
代码:
三.效果图展示
3.1图示
3.2代码
3.3代码下载地址
https://jackieling.github.io/Temperature_Control/.
链接:https://pan.baidu.com/s/1gcev1XFanHTPIY2ahJ4d0A
提取码:zgu9
边栏推荐
- mysql索引
- Custom filters and interceptors implement ThreadLocal thread closure
- 还在找网盘资源吗?快点收藏如下几个值得收藏的网盘资源搜索神器吧!
- IO stream articles -- based on io stream to realize folder copy (copy subfolders and files in subfolders) full of dry goods
- 自定义过滤器和拦截器实现ThreadLocal线程封闭
- Wei Dongshan Digital Photo Frame Project Learning (6) Transplantation of tslib
- How to realize the short press and long press detection of the button?
- 告白数字化转型时代:麦聪软件以最简单的方式让企业把数据用起来
- ffmpeg drawtext add text watermark
- Marketing Suggestions | You have an August marketing calendar to check! Suggest a collection!
猜你喜欢
2022华数杯数学建模A题环形振荡器的优化设计思路思路代码分享
egg框架使用(二)
轩辕实验室丨欧盟EVITA项目预研 第一章(四)
百年北欧奢华家电品牌ASKO智能三温区酒柜臻献七夕,共品珍馐爱意
电竞、便捷、高效、安全,盘点OriginOS功能的关键词
After Keil upgrades to AC6, what changes?
上海控安技术成果入选市经信委《2021年上海市网络安全产业创新攻关成果目录》
First Decentralized Heist?Loss of nearly 200 million US dollars: analysis of the attack on the cross-chain bridge Nomad
Oracle temporary table space role
19.服务器端会话技术Session
随机推荐
PAT Grade B-B1020 Mooncake(25)
Offensive World-PWN-new_easypwn
What is CRM Decision Analysis Management?
企业的数字化转型到底是否可以买来?
Advanced usage of C language
自定义过滤器和拦截器实现ThreadLocal线程封闭
【MindSpore Easy-Diantong Robot-01】You may have seen many knowledge quiz robots, but this one is a bit different
What is the function of the regular expression replaceFirst() method?
Brief Analysis of WSGI Protocol
Our Web3 Entrepreneurship Project, Yellow
高质量 DeFi 应用构建指南,助力开发者玩转 DeFi Summer
2022华数杯数学建模思路分析交流
仿SBUS与串口数据固定转换
CCVR eases heterogeneous federated learning based on classifier calibration
皕杰报表的下拉框联动
无题十二
技术干货 | 基于 MindSpore 实现图像分割之豪斯多夫距离
Analysis and practice of antjian webshell dynamic encrypted connection
2.4G无线收发模块的应用
蚁剑webshell动态加密连接分析与实践