当前位置: 首页 > news >正文

C# Task.WaitAll 的用法

目录

简介

1.WaitAll(Task[], Int32, CancellationToken)

2.WaitAll(Task[])

3.WaitAll(Task[], Int32)

4.WaitAll(Task[], CancellationToken)

5.WaitAll(Task[], TimeSpan)

结束


简介

Task.WaitAll 是 C# 中用于并行编程的一个的方法,它属于 System.Threading.Tasks 命名空间。主要作用是等待提供的所有 Task 对象完成其执行过程。通过使用 Task.WaitAll,开发者可以确保一组并行执行的任务全部完成后,再继续执行后续的代码。这对于需要等待多个异步操作同时完成以继续执行其他操作的场景非常有用。

Task.WaitAll 方法有多个重载版本,以适应不同的需求。最基本的版本接收一个 Task 对象的数组作为参数,并等待这个数组中的所有任务完成。如果所有任务都成功完成,则该方法正常返回;如果有任何任务在执行过程中抛出了异常,这些异常会被封装在 AggregateException 中并抛出。如果任务被取消,AggregateException 的 InnerExceptions 集合中会包含 OperationCanceledException。

Task.WaitAll 还提供了带有超时和取消令牌的重载方法,允许开发者在指定的时间间隔内等待所有任务完成,或者如果等待被取消,则提前退出等待。这些重载版本为处理超时和取消操作提供了更灵活的方式。

Task.WaitAll 方法适用于多种场景,如同时处理多个数据库查询、同时下载多个文件或执行任何需要并行处理的任务集合。通过并行处理,可以显著提高应用程序的响应速度和吞

打开你的项目,利用 Visual Studio 2022 反编译功能看看当前的 WaitAll 是那个对应的版本,比如下图,我用的是 .NetFramework 4.8 

官方文档:点击跳转

定义
命名空间:
System.Threading.Tasks
程序集:
System.Runtime.dll
等待提供的所有 Task 对象完成执行过程。

WaitAll(Task[], Int32, CancellationToken)等待提供的所有 Task 对象在指定的毫秒数内完成执行,或等到取消等待
WaitAll(Task[])等待提供的所有 Task 对象完成执行过程。
WaitAll(Task[], Int32)等待所有提供的 Task 在指定的毫秒数内完成执行
WaitAll(Task[], CancellationToken)等待提供的所有 Task 对象完成执行过程(除非取消等待)
WaitAll(Task[], TimeSpan)等待所有提供的可取消 Task 对象在指定的时间间隔内完成执行

1.WaitAll(Task[], Int32, CancellationToken)

等待提供的所有 Task 对象在指定的毫秒数内完成执行,或等到取消等待。

[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static bool WaitAll (System.Threading.Tasks.Task[] tasks, int millisecondsTimeout, System.Threading.CancellationToken cancellationToken);

参数
tasks  Task[]
要等待的 Task 实例的数组。

millisecondsTimeout  Int32
等待的毫秒数,或为 Infinite (-1),表示无限期等待。

cancellationToken  CancellationToken
等待任务完成期间要观察的 CancellationToken。

返回
Boolean
如果在分配的时间内所有 true 实例都已完成执行,则为 Task;否则为 false。

属性 UnsupportedOSPlatformAttribute


例外
ObjectDisposedException
tasks 中的一个或多个 Task 对象已释放。

ArgumentNullException
tasks 参数为 null。

AggregateException
至少一个 Task 实例已取消。 如果任务已取消,则 AggregateException 在其 InnerExceptions 集合中包含 OperationCanceledException。

- 或 -

在至少一个 Task 实例的执行过程中引发了异常。

ArgumentOutOfRangeException
millisecondsTimeout 是一个非 -1 的负数,而 -1 表示无限期超时。

ArgumentException
tasks 参数包含一个 null 元素。

OperationCanceledException
已取消 cancellationToken。

注解
参数 cancellationToken 用于取消等待操作。 取消任务是一项不同的操作,由 AggregateException 上面提到的 发出信号。

Task.WaitAll 方法是并行执行所有传入的任务,而不是按顺序一个接一个地执行。Task 是基于 .NET 的异步编程模型,利用多核 CPU 的优势来提高性能,并同时多个任务执行。

Task.WaitAll 在执行时,所有的任务会几乎同时启动,具体的执行顺序取决于线程调度和系统资源。系统会根据可用的线程和 CPU 核心来调度这些任务。这意味着,任务的完成顺序可能与它们在代码中添加到列表的顺序不同。

Task.WaitAll 方法会阻塞调用线程,直到所有任务都完成。

新建一个 .NET Framework 4.8 的 控制台项目,就当前的方法写一个案例:

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;namespace task_test1
{internal class Program{static CancellationTokenSource cts = new CancellationTokenSource();static void Main(string[] args){int timeout = 1000;List<Task<(string, bool)>> taskList = new List<Task<(string, bool)>>();taskList.Add(PingTest("https://github.com/"));taskList.Add(PingTest("https://www.csdn.net/"));taskList.Add(PingTest("https://www.zhihu.com/"));taskList.Add(PingTest("https://www.microsoft.com/zh-cn/"));taskList.Add(PingTest("https://www.baidu.com/"));Task<(string, bool)>[] tasks = taskList.ToArray();try{bool allCompleted = Task.WaitAll(tasks, timeout, cts.Token);Console.WriteLine("执行结果:{0}", allCompleted);foreach (var task in tasks){var tuple = task.Result;Console.WriteLine($"result:{tuple.Item2},url:{tuple.Item1}");}}catch (Exception ex){Console.WriteLine("错误:{0}", ex.Message);}Console.ReadKey();}static async Task<(string, bool)> PingTest(string ip){cts.Token.ThrowIfCancellationRequested();PingTool tool = new PingTool();bool result = await tool.Ping(ip, cts);return (ip, result);}}
}internal class PingTool
{public async Task<bool> Ping(string url, CancellationTokenSource cts){if (string.IsNullOrEmpty(url))return false;try{using (HttpClient client = new HttpClient()){client.Timeout = TimeSpan.FromSeconds(5);cts.Token.ThrowIfCancellationRequested();var response = await client.GetAsync(url, cts.Token);return response.IsSuccessStatusCode;}}catch (Exception){return false;}}
}

运行:

代码中 int timeout = 1000,也就是1秒,在超时的情况下,Task.WaitAll 会返回 false,但是5个 Task 依然全部执行了,所以,timeout 影响的也只有 task 的返回结果了

不超时会返回 true


 

2.WaitAll(Task[])

等待提供的所有 Task 对象完成执行过程。

[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static void WaitAll (params System.Threading.Tasks.Task[] tasks);

参数

tasks  Task[]
要等待的 Task 实例的数组。

属性  UnsupportedOSPlatformAttribute


例外
ObjectDisposedException
tasks 中的一个或多个 Task 对象已释放。

ArgumentNullException
tasks 参数为 null。

ArgumentException
tasks 参数包含一个 null 元素。

AggregateException
至少一个 Task 实例已取消。 如果任务取消,则 AggregateException 异常在其 InnerExceptions 集合中包含 OperationCanceledException 异常。

- 或 -

在至少一个 Task 实例的执行过程中引发了异常
 

C# 案例:

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;namespace task_test1
{internal class Program{static void Main(string[] args){List<Task<(string, bool)>> taskList = new List<Task<(string, bool)>>();taskList.Add(PingTest("https://www.csdn.net/"));taskList.Add(PingTest("https://www.zhihu.com/"));taskList.Add(PingTest("https://www.microsoft.com/zh-cn/"));taskList.Add(PingTest("https://www.baidu.com/"));taskList.Add(PingTest("https://github.com/"));Task.WaitAll(taskList.ToArray());Console.ReadKey();}static async Task<(string, bool)> PingTest(string ip){PingTool tool = new PingTool();bool result = await tool.Ping(ip);Console.WriteLine("result:{0},时间:{1},url:{2}", result, DateTime.Now, ip);return (ip, result);}}
}internal class PingTool
{public async Task<bool> Ping(string url){if (string.IsNullOrEmpty(url))return false;try{using (HttpClient client = new HttpClient()){client.Timeout = TimeSpan.FromSeconds(5);var response = await client.GetAsync(url);return response.IsSuccessStatusCode;}}catch (System.Exception){return false;}}
}

运行:

3.WaitAll(Task[], Int32)

等待所有提供的 Task 在指定的毫秒数内完成执行。

[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static bool WaitAll (System.Threading.Tasks.Task[] tasks, int millisecondsTimeout);

参数
tasks  Task[]
要等待的 Task 实例的数组。

millisecondsTimeout  Int32
等待的毫秒数,或为 Infinite (-1),表示无限期等待。

返回
Boolean
如果在分配的时间内所有 true 实例都已完成执行,则为 Task;否则为 false。

属性   UnsupportedOSPlatformAttribute


例外
ObjectDisposedException
tasks 中的一个或多个 Task 对象已释放。

ArgumentNullException
tasks 参数为 null。

AggregateException
至少一个 Task 实例已取消。 如果任务已取消,则 AggregateException 在其 InnerExceptions 集合中包含 OperationCanceledException。

- 或 -

在至少一个 Task 实例的执行过程中引发了异常。

ArgumentOutOfRangeException
millisecondsTimeout 是一个非 -1 的负数,而 -1 表示无限期超时。

ArgumentException
tasks 参数包含一个 null 元素。

C# 案例:

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;namespace task_test1
{internal class Program{static void Main(string[] args){int timeout = 3000;List<Task<(string, bool)>> taskList = new List<Task<(string, bool)>>();taskList.Add(PingTest("https://github.com/"));taskList.Add(PingTest("https://www.csdn.net/"));taskList.Add(PingTest("https://www.zhihu.com/"));taskList.Add(PingTest("https://www.microsoft.com/zh-cn/"));taskList.Add(PingTest("https://www.baidu.com/"));Task<(string, bool)>[] tasks = taskList.ToArray();bool allCompleted = Task.WaitAll(tasks, timeout);Console.WriteLine("执行结果:{0}", allCompleted);foreach (var task in tasks){var tuple = task.Result;Console.WriteLine($"result:{tuple.Item2},url:{tuple.Item1}");}Console.ReadKey();}static async Task<(string, bool)> PingTest(string ip){PingTool tool = new PingTool();bool result = await tool.Ping(ip);return (ip, result);}}
}internal class PingTool
{public async Task<bool> Ping(string url){if (string.IsNullOrEmpty(url))return false;try{using (HttpClient client = new HttpClient()){client.Timeout = TimeSpan.FromSeconds(5);var response = await client.GetAsync(url);return response.IsSuccessStatusCode;}}catch (System.Exception){return false;}}
}

运行:

4.WaitAll(Task[], CancellationToken)

等待提供的所有 Task 对象完成执行过程(除非取消等待)。

[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static void WaitAll (System.Threading.Tasks.Task[] tasks, System.Threading.CancellationToken cancellationToken);

参数
tasks  Task[]
要等待的 Task 实例的数组。

cancellationToken  CancellationToken
等待任务完成期间要观察的 CancellationToken。

属性  UnsupportedOSPlatformAttribute


例外
OperationCanceledException
已取消 cancellationToken。

ArgumentNullException
tasks 参数为 null。

AggregateException
至少一个 Task 实例已取消。 如果任务已取消,则 AggregateException 在其 InnerExceptions 集合中包含 OperationCanceledException。

- 或 -

在至少一个 Task 实例的执行过程中引发了异常。

ArgumentException
tasks 参数包含一个 null 元素。

ObjectDisposedException
tasks 中的一个或多个 Task 对象已释放。

注解
参数 cancellationToken 用于取消等待操作。 取消任务是一项不同的操作,由 如上所述的 发出信号 AggregateException 。

关于取消任务为什么后续依然执行了,请参考第1节的解释

C# 案例:

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;namespace task_test1
{internal class Program{static CancellationTokenSource cts = new CancellationTokenSource();static void Main(string[] args){List<Task<(string, bool)>> taskList = new List<Task<(string, bool)>>();taskList.Add(PingTest("https://github.com/"));taskList.Add(PingTest("https://www.csdn.net/"));taskList.Add(PingTest("https://www.zhihu.com/"));taskList.Add(PingTest("https://www.microsoft.com/zh-cn/"));taskList.Add(PingTest("https://www.baidu.com/"));Task<(string, bool)>[] tasks = taskList.ToArray();Task.Run(() =>{Thread.Sleep(100);Console.WriteLine("取消任务");cts.Cancel();});Console.WriteLine("开始执行任务");try{Task.WaitAll(tasks, cts.Token);}catch (Exception ex){Console.WriteLine("错误:{0}", ex.Message);}Console.ReadKey();}static async Task<(string, bool)> PingTest(string ip){//方法 Task.WaitAll 执行任务会同时执行所有的Task,并等待任务完成//而不是一个个按顺序来执行,然后等待结果,所以注释的代码无效//if (cts.Token.IsCancellationRequested) //{//    Console.WriteLine($"Task for {ip} was cancelled before execution.");//    return (ip, false);//}//cts.Token.ThrowIfCancellationRequested();PingTool tool = new PingTool();bool result = await tool.Ping(ip, cts);Console.WriteLine("result:{0},url:{1}", result, ip);return (ip, result);}}
}internal class PingTool
{public async Task<bool> Ping(string url, CancellationTokenSource cts){if (string.IsNullOrEmpty(url))return false;try{using (HttpClient client = new HttpClient()){client.Timeout = TimeSpan.FromSeconds(5);cts.Token.ThrowIfCancellationRequested();var response = await client.GetAsync(url, cts.Token);return response.IsSuccessStatusCode;}}catch (Exception){return false;}}
}

运行:

5.WaitAll(Task[], TimeSpan)

等待所有提供的可取消 Task 对象在指定的时间间隔内完成执行。

[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static bool WaitAll (System.Threading.Tasks.Task[] tasks, TimeSpan timeout);

参数
tasks  Task[]
要等待的 Task 实例的数组。

timeout  TimeSpan
表示等待毫秒数的 TimeSpan,或表示 -1 毫秒(无限期等待)的 TimeSpan。

返回
Boolean
如果在分配的时间内所有 true 实例都已完成执行,则为 Task;否则为 false。

属性  UnsupportedOSPlatformAttribute


例外
ObjectDisposedException
tasks 中的一个或多个 Task 对象已释放。

ArgumentNullException
tasks 参数为 null。

AggregateException
至少一个 Task 实例已取消。 如果任务已取消,则 AggregateException 在其 InnerExceptions 集合中包含 OperationCanceledException。

- 或 -

在至少一个 Task 实例的执行过程中引发了异常。

ArgumentOutOfRangeException
timeout 为 -1 毫秒以外的负数,表示无限期超时。

- 或 -

timeout 大于 Int32.MaxValue。

ArgumentException
tasks 参数包含一个 null 元素。
 

C# 案例:

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;namespace task_test1
{internal class Program{static void Main(string[] args){List<Task<(string, bool)>> taskList = new List<Task<(string, bool)>>();taskList.Add(PingTest("https://github.com/"));taskList.Add(PingTest("https://www.csdn.net/"));taskList.Add(PingTest("https://www.zhihu.com/"));taskList.Add(PingTest("https://www.microsoft.com/zh-cn/"));taskList.Add(PingTest("https://www.baidu.com/"));Task<(string, bool)>[] tasks = taskList.ToArray();bool allCompleted = Task.WaitAll(tasks, TimeSpan.FromSeconds(1));Console.WriteLine("执行结果:{0}", allCompleted);foreach (var task in tasks){var tuple = task.Result;Console.WriteLine($"result:{tuple.Item2},url:{tuple.Item1}");}Console.ReadKey();}static async Task<(string, bool)> PingTest(string ip){PingTool tool = new PingTool();bool result = await tool.Ping(ip);return (ip, result);}}
}internal class PingTool
{public async Task<bool> Ping(string url){if (string.IsNullOrEmpty(url))return false;try{using (HttpClient client = new HttpClient()){client.Timeout = TimeSpan.FromSeconds(5);var response = await client.GetAsync(url);return response.IsSuccessStatusCode;}}catch (System.Exception){return false;}}
}

运行:

结束

如果这个帖子对你有用,欢迎 关注 + 点赞 + 留言,谢谢

end

相关文章:

C# Task.WaitAll 的用法

目录 简介 1.WaitAll(Task[], Int32, CancellationToken) 2.WaitAll(Task[]) 3.WaitAll(Task[], Int32) 4.WaitAll(Task[], CancellationToken) 5.WaitAll(Task[], TimeSpan) 结束 简介 Task.WaitAll 是 C# 中用于并行编程的一个的方法&#xff0c;它属于 System.Threa…...

vue2 前端实现pdf在线预览(无插件版)

toFielDetail()是点击预览的方法&#xff0c;getOfficialFile是获取文件流的接口正常定义即可&#xff1a; export function getOfficialFile(query) {return request({url: /dataAsset/projectassess/getOfficialFile,method: get,params: query,}); } 调用接口的页面需要引用…...

排序XXXXXXXXX

信息学奥赛&#xff5c;常见排序算法总结&#xff08;C&#xff0b;&#xff09; - 腾讯云开发者社区-腾讯云 (tencent.com) https://cloud.tencent.com/developer/news/975232 常用序号层级排序 一、序号 序号Sequence Number&#xff0c;有顺序的号码&#xff0c;如数字序号…...

【文件解析漏洞】实战详解!

漏洞描述&#xff1a; 文件解析漏洞是由于中间件错误的将任意格式的文件解析成网页可执行文件&#xff0c;配合文件上传漏洞进行GetShell的漏洞! IIS解析漏洞&#xff1a; IIS6.X&#xff1a; 方式一:目录解析 在网站下建立文件夹的名字为.asp/.asa 的文件夹&#xff0c;其目…...

【杂谈】学会让你节省三秒钟——Dev-c++的缺省源

【杂谈】学会让你节省三秒钟——Dev-c的缺省源 1.前言2.缺省源的介绍3.注意 1.前言 你是否在为每次写程序都要自己手打一遍框架而感到苦恼&#xff1f;为什么大佬的Dev-C一新建文件就会自动出现程序框架&#xff1f;看完这篇文章&#xff0c;让你也能成为大佬&#xff0c;不用再…...

推荐一款前端滑动验证码插件(Vue、uniapp)

uniapp版本&#xff1a;滑块拼图验证码&#xff0c;有后端&#xff0c;简单几步即可实现&#xff0c;小程序、h5都可以用 - DCloud 插件市场 Vue版本及cdn版本可以查阅文档&#xff1a; 行为验证 | Poster 文档 示例代码&#xff1a; <template><view id"app&…...

【Git】git stash

目录 基本概念参数详解listshowsavepushpop|applydropclearbranch 参考文章 Git的stash命令是一个非常实用的功能&#xff0c;它允许开发者临时保存工作目录和暂存区的更改&#xff0c;以便能够切换到其他分支或进行其他操作&#xff0c;而不会丢失当前的修改。以下是git stash…...

不得不安利的程序员开发神器,太赞了!!

作为一名程序员&#xff0c;你是否常常为繁琐的后端服务而感到头疼&#xff1f;是否希望有一种工具可以帮你简化开发流程&#xff0c;让你专注于创意和功能开发&#xff1f;今天&#xff0c;我要向大家隆重推荐一款绝佳的开发神器——MemFire Cloud。它专为懒人开发者准备&…...

吴恩达机器学习C1W2Lab06-使用Scikit-Learn进行线性回归

前言 有一个开源的、商业上可用的机器学习工具包&#xff0c;叫做scikit-learn。这个工具包包含了你将在本课程中使用的许多算法的实现。 目标 在本实验室你可以&#xff1a; 利用scikit-learn实现基于正态方程的近似解线性回归 工具 您将使用scikit-learn中的函数以及ma…...

CSS实现表格无限轮播

<div className{styles.tableTh}><div className{styles.thItem} style{{ width: 40% }}>报警名称</div><div className{styles.thItem} style{{ width: 35% }}>开始时间</div><div className{styles.thItem} style{{ width: 25% }}>状态&…...

编程小白如何从迷茫走出

针对新生们常常感到的迷茫&#xff0c;以下是如何选择适合自己的编程语言、如何制定有效的学习计划以及如何避免常见的学习陷阱的详细建议&#xff1a; 一、如何选择适合自己的编程语言 明确需求和目标&#xff1a;不同的编程语言有不同的特点和适用场景。例如&#xff0c;Py…...

14 B端产品的运营管理

通过运营找到需求并通过交换价值提供供给&#xff0c;再逐步扩大规模、站稳脚跟&#xff0c;辅助产品在商业竞争中获胜。 B端产品运营框架 1. 打通渠道 目的&#xff1a;触达客户。 环节&#xff1a;文案策划、活动策划→广告渠道推广→线下BD。 线下BD&#xff1a;通过见面…...

STM32_RTOS学习笔记——1(列表与列表项)

总体RTOS笔记目录 一&#xff0c;列表与列表项&#xff08;本文&#xff09; 二&#xff0c;待定 视频参考&#xff1a;B站野火 一&#xff0c;C语言列表概念 列表就是C语言中的链表&#xff0c;链表就如同下面的衣架一样&#xff0c;需要的各种内容可以参考 C语言链表可…...

子网划分案例

划分子网是将一个较大的网络划分为多个较小的子网&#xff0c;以提高网络管理和安全性 子网划分可以更有效地利用 IP 地址空间&#xff0c;并且有助于控制网络流量、提高网络性能和安全性。 子网划分的主要步骤如下&#xff1a; 确定需要划分的子网数量以及每个子网所需的主…...

javaweb_02:Maven

一、引入 在javaweb的开发中&#xff0c;需要使用大量的jar包&#xff0c;我们得手动去导入&#xff0c;而Maven可以自动帮我们导入和配置这个jar包。 二、Maven项目框架管理工具 核心思想&#xff1a;约定大于配置&#xff08;有约束不违反&#xff09;&#xff1a;Maven会…...

19.延迟队列优化

问题 前面所讲的延迟队列有一个不足之处&#xff0c;比如现在有一个需求需要延迟半个小时的消息&#xff0c;那么就只有添加一个新的队列。那就意味着&#xff0c;每新增一个不同时间需求&#xff0c;就会新创建一个队列。 解决方案 应该讲消息的时间不要跟队列绑定&#xf…...

P10477 Subway tree systems 题解,c++ 树相关题目

题目 poj 链接 洛谷链接 n n n 组数据&#xff0c;每组数据给定两个 01 01 01 串&#xff08;长度不超过 3000 3000 3000&#xff09;&#xff0c;意思如下&#xff1a; 对于每一个 0 0 0&#xff0c;代表该节点有一个子节点&#xff0c;并前往该子节点。对于每一个 1 1 …...

18.jdk源码阅读之CopyOnWriteArrayList

1. 写在前面 CopyOnWriteArrayList 是 Java 中的一种线程安全的 List 实现&#xff0c;基于“写时复制”&#xff08;Copy-On-Write&#xff09;机制。下面几个问题大家可以先思考下&#xff0c;在阅读源码的过程中都会解答&#xff1a; CopyOnWriteArrayList 适用于哪些场景…...

美股:AMD展现乐观前景,挑战AI加速器市场霸主

在科技行业的激烈竞争中&#xff0c;AMD公司近期发布了对当前季度收入的乐观预测&#xff0c;显示出其新推出 一、AMD第三季度营收预期超越分析师平均预期 AMD在周二的声明中预计&#xff0c;第三季度营收将达到约67亿美元&#xff0c;这一数字超出了分析师此前平均预期的66.…...

如何提高计算机视觉技术在复杂环境和低光照条件下的物体识别准确率?

要在复杂环境和低光照条件下提高计算机视觉技术的物体识别准确率&#xff0c;可以采取以下几个方法&#xff1a; 数据增强&#xff1a;在训练集中添加各种复杂环境和低光照条件下的图片&#xff0c;通过增加数据的多样性&#xff0c;使算法能够更好地适应各种场景。 预处理&am…...

用PlantUML+C4模型轻松绘制软件架构图:实战电商系统设计案例

用PlantUMLC4模型构建电商系统架构图&#xff1a;从理论到实践 在当今快速迭代的软件开发领域&#xff0c;清晰的架构设计文档已成为团队协作的基石。然而&#xff0c;传统绘图工具往往让开发者陷入"美化图表"的泥潭&#xff0c;反而忽视了架构设计的本质思考。本文将…...

ESP32 SD卡固件更新库:DSTIKE OLED图形化OTA引导方案

1. 项目概述DstikeUpdater 是一个专为 DSTIKE 系列 ESP32 开发板设计的嵌入式固件在线更新&#xff08;Over-the-Air, OTA&#xff09;辅助库&#xff0c;其核心定位并非替代 ESP-IDF 或 Arduino-ESP32 原生 OTA 机制&#xff0c;而是构建一套面向终端用户的、具备图形化交互能…...

CHORD-X深度研究报告生成终端ComfyUI可视化工作流集成教程

CHORD-X深度研究报告生成终端ComfyUI可视化工作流集成教程 你是不是也遇到过这样的场景&#xff1a;需要生成一份深度行业分析报告&#xff0c;手头有CHORD-X这样强大的研究工具&#xff0c;但每次都要写代码调用API&#xff0c;流程繁琐&#xff0c;调试起来也不直观。或者&a…...

NX二次开发自动化签名与部署:DLL编译后处理全攻略

1. 为什么需要自动化签名与部署&#xff1f; 做过NX二次开发的朋友都知道&#xff0c;每次修改代码后都要手动签名和部署DLL文件&#xff0c;这个过程简直让人抓狂。我刚开始做NX插件开发时&#xff0c;经常因为忘记签名导致测试失败&#xff0c;来回折腾特别浪费时间。后来发…...

编写程序让智能门禁红外检测到人体逗留超10秒,自动提示“请勿逗留”,适配小区安防。

智能门禁红外检测系统 - 社区安防解决方案 一、实际应用场景描述 某老旧小区改造项目&#xff0c;原门禁系统仅支持刷卡/密码开门&#xff0c;存在以下问题&#xff1a; - 外卖员/访客长时间在门口逗留&#xff0c;易引发盗窃或纠纷 - 物业无法实时获知异常停留情况 - 传统系…...

OpenCV颜色查找表LUT的5个高级用法:从图像反转到颜色空间缩减

OpenCV颜色查找表LUT的5个高级用法&#xff1a;从图像反转到颜色空间缩减 在数字图像处理领域&#xff0c;颜色查找表&#xff08;Look Up Table&#xff0c;简称LUT&#xff09;是一种高效且强大的工具。它通过预先计算的映射关系&#xff0c;能够实现像素值的快速转换&#x…...

从零到一:手把手教你用Android Studio离线打包UniApp安卓应用

1. 环境准备&#xff1a;搭建离线打包的基础设施 第一次接触UniApp离线打包时&#xff0c;最让人头疼的就是环境配置。记得我刚开始尝试时&#xff0c;光是安装Android Studio就反复折腾了三遍。这里我会把踩过的坑都帮你避开&#xff0c;让你一次性搞定所有依赖。 首先需要准备…...

降重压力小了!全领域适配的降AIGC神器 —— 千笔

在AI技术迅猛发展的今天&#xff0c;越来越多的学生和研究人员开始依赖AI工具进行论文写作&#xff0c;以提高效率和质量。然而&#xff0c;随着学术审核标准的不断提升&#xff0c;AI生成内容的痕迹越来越容易被检测出来&#xff0c;导致论文出现“AI率超标”问题&#xff0c;…...

Windows计划任务终极指南:从schtasks命令到GUI管理全解析(含常见错误排查)

Windows计划任务全栈管理&#xff1a;从基础配置到企业级运维实战 凌晨三点&#xff0c;服务器突然告警——关键备份任务未能执行。作为运维工程师&#xff0c;你是否经历过这种被计划任务"放鸽子"的噩梦&#xff1f;Windows计划任务系统远不止是简单的定时触发器&am…...

OpenClaw浏览器控制:GLM-4.7-Flash智能爬虫实战

OpenClaw浏览器控制&#xff1a;GLM-4.7-Flash智能爬虫实战 1. 为什么需要无代码爬虫&#xff1f; 作为数据分析师&#xff0c;我每天要处理大量网页数据收集工作。传统爬虫开发需要处理反爬机制、页面结构解析、数据清洗等复杂环节&#xff0c;一个简单的需求往往要写上百行…...