摘要: 问题 #include<iostream> #include<thread> int main() { int sum = 0; auto f = [&sum]() { for (int i = 0; i < 10000; i++) sum += 1; }; std::thread t1(f); s 阅读全文
posted @ 2024-03-31 14:00 robot2017 阅读(56) 评论(0) 推荐(0) 编辑
摘要: 背景及问题 如下程序所示: #include<iostream> class MyString { public: MyString() = default; MyString(const char* data) { printf("%s", "MyString Constructed!!\n"); 阅读全文
posted @ 2023-12-19 12:04 robot2017 阅读(61) 评论(0) 推荐(0) 编辑
摘要: 背景及问题: 在与硬件打交道时,经常需要知道当前设备连接的硬件信息,以便连接正确的硬件,比如串口通讯查询连接的硬件及端口,一般手工的方式就是去设备管理器查看相应的信息,应用程序如何读取这一部分信息呢,Windows下的SetupAPI系列就可以解决这个问题 示例程序 #include<Windows 阅读全文
posted @ 2023-12-12 23:14 robot2017 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 背景及问题: 目前很多局域网设备通过mNDS协议实现互联,IP地址为自动IP段-169.254.x.x,有时候设备厂家提供的API需要通过知晓局域网中的IP地址/设备名,才能连接该设备。这样要求每个软件必须配置设备名或者启动时遍历所有IP(6w+),不是很方便,这时候可以通过mDNS查询,自动拿到设 阅读全文
posted @ 2023-11-22 21:41 robot2017 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 问题: 上一篇async/await 致WPF卡死问题(https://www.cnblogs.com/stephen2023/p/17725159.html),介绍主线程阻塞,async/await导致卡死问题,同样的代码在console下却并不会出现卡死。 static Stopwatch sw 阅读全文
posted @ 2023-09-24 22:41 robot2017 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 问题代码: xmal:一个按钮+一个显示框 1 <Button Width="100" Height="50" Margin="10" Click="Button_Click">test</Button> 2 <TextBox x:Name="display" Width="300" Height= 阅读全文
posted @ 2023-09-23 21:52 robot2017 阅读(308) 评论(0) 推荐(0) 编辑
摘要: 问题代码: 1 #include<windows.h> 2 #include<iostream> 3 #include<thread> 4 HANDLE h1; 5 HANDLE h2; 6 7 void CALLBACK test(PVOID a, BOOLEAN b) 8 { 9 std::co 阅读全文
posted @ 2023-08-26 17:59 robot2017 阅读(144) 评论(0) 推荐(0) 编辑