当前位置:网站首页>【 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,它是从EventArgsAre 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
边栏推荐
- 正则表达式replaceFirst()方法具有什么功能呢?
- 2022.8.3
- 高质量 DeFi 应用构建指南,助力开发者玩转 DeFi Summer
- 无题十三
- dotnet OpenXML 解析 PPT 图表 面积图入门
- JS逆向入门学习之回收商网,手机号码简易加密解析
- Why are RELTABLESPACE values 0 for many tables displayed in sys_class?
- 5. Deploy the web project to the cloud server
- Custom filters and interceptors implement ThreadLocal thread closure
- 哪位大佬有20年4月或者1月的11G GI和ojvm补丁呀,帮忙发下?
猜你喜欢

2022华数杯数学建模A题环形振荡器的优化设计思路思路代码分享

开源一夏|OpenHarmony如何查询设备类型(eTS)

js graphics operation one (compatible with pc, mobile terminal to achieve draggable attribute drag and drop effect)

【MindSpore易点通机器人-01】你也许见过很多知识问答机器人,但这个有点不一样

Pytorch深度学习快速入门教程 -- 土堆教程笔记(三)

After Keil upgrades to AC6, what changes?

5. Deploy the web project to the cloud server

【温度预警程序de开发】事件驱动模型实例运用

上海控安技术成果入选市经信委《2021年上海市网络安全产业创新攻关成果目录》

阿里顶级架构师多年总结的JVM宝典,哪里不会查哪里!
随机推荐
偏向锁/轻量锁/重级锁锁锁更健康,上锁解锁到底是怎么完成实现的
Handwriting Currying - toString Comprehension
IDEA performs the Test operation, resulting in duplicate data when data is inserted
阿里顶级架构师多年总结的JVM宝典,哪里不会查哪里!
What is SPL?
Dry goods!Generative Model Evaluation and Diagnosis
leetcode: 529. 扫雷游戏
无题五
What is the function of the regular expression replaceFirst() method?
Pycharm 常用外部工具
Qiu Jun, CEO of Eggplant Technology: Focus on users and make products that users really need
2022-08-01 Review the basic binary tree and operations
The technological achievements of Shanghai Konan were selected into the "2021 Shanghai Network Security Industry Innovation Research Achievement Catalog" by the Municipal Commission of Economy and Inf
hcip BGP 增强实验
哪位大佬有20年4月或者1月的11G GI和ojvm补丁呀,帮忙发下?
一文道清什么是SPL
仿SBUS与串口数据固定转换
JS逆向入门学习之回收商网,手机号码简易加密解析
Redis源码解析:Redis Cluster
无题十四