当前位置:网站首页>【 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
边栏推荐
- 【Unity】【UGUI】【在屏幕上显示文本】
- Why are RELTABLESPACE values 0 for many tables displayed in sys_class?
- 语音社交软件开发——充分发挥其价值
- 新白娘子传奇系列
- Pycharm 常用外部工具
- LeetCode 216. Combined Sum III (2022.08.04)
- 公众号如何运维?公众号运维专业团队
- IDEA performs the Test operation, resulting in duplicate data when data is inserted
- Pytorch Deep Learning Quick Start Tutorial -- Mound Tutorial Notes (3)
- 一文道清什么是SPL
猜你喜欢

Science bosses say | Hong Kong rhubarb KaiBin teacher take you unlock the relationship between the matrix and 6 g

egg框架使用(二)

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

还在找网盘资源吗?快点收藏如下几个值得收藏的网盘资源搜索神器吧!

Technical dry goods | Hausdorff distance for image segmentation based on MindSpore

轩辕实验室丨欧盟EVITA项目预研 第一章(四)

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

气象数据数据处理实例——matlab字符串切割匹配与R语言日期匹配(数据拼接)

leetcode: 529. 扫雷游戏

Pytorch深度学习快速入门教程 -- 土堆教程笔记(三)
随机推荐
three.js调试工具dat.gui使用
dotnet OpenXML 解析 PPT 图表 面积图入门
Four years of weight loss record
PAT乙级-B1021 个位数统计(15)
Dry goods!Generative Model Evaluation and Diagnosis
我们的Web3创业项目,黄了
Our Web3 Entrepreneurship Project, Yellow
The difference between find, matches, lookingAt matching strings in matcher
Microservice Technology Stack
无题十
static linking and dynamic linking
21 Days of Deep Learning - Convolutional Neural Networks (CNN): Weather Recognition (Day 5)
创建一个 Dapp,为什么要选择波卡?
高质量 DeFi 应用构建指南,助力开发者玩转 DeFi Summer
What is SPL?
dotnet OpenXML parsing PPT charts Getting started with area charts
How can project cost control help project success?
PAT Class B-B1019 Digital Black Hole (20)
IO流篇 -- 基于io流实现文件夹拷贝(拷贝子文件夹及子文件夹内文件)满满的干货
无题八