当前位置:网站首页>【 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
边栏推荐
- Pytorch Deep Learning Quick Start Tutorial -- Mound Tutorial Notes (3)
- 浅析WSGI协议
- Imitation SBUS fixed with serial data conversion
- 无题九
- 开发常用手册链接分享
- 我们的Web3创业项目,黄了
- The difference between find, matches, lookingAt matching strings in matcher
- Can MySQL use aggregate functions without GROUP BY?
- LeetCode 216. Combined Sum III (2022.08.04)
- Analysis and practice of antjian webshell dynamic encrypted connection
猜你喜欢
随机推荐
PAT Grade B-B1020 Mooncake(25)
数据中台建设(十):数据安全管理
Complete image segmentation efficiently based on MindSpore and realize Dice!
自定义过滤器和拦截器实现ThreadLocal线程封闭
上海控安技术成果入选市经信委《2021年上海市网络安全产业创新攻关成果目录》
IDEA执行Test操作导致数据插入时出现了重复数据
我们的Web3创业项目,黄了
shell脚本实例
How can project cost control help project success?
【MindSpore易点通机器人-01】你也许见过很多知识问答机器人,但这个有点不一样
开源一夏|OpenHarmony如何查询设备类型(eTS)
入门 Polkadot 平行链开发,看这一篇就够了
What is the function of the regular expression replaceAll() method?
IO流篇 -- 基于io流实现文件夹拷贝(拷贝子文件夹及子文件夹内文件)满满的干货
Analysis and practice of antjian webshell dynamic encrypted connection
PHP 操作mangoDb
基于MindSpore高效完成图像分割,实现Dice!
皕杰报表的下拉框联动
19. Server-side session technology Session
uniapp 连接ibeacon