C#中WPF使用多线程调用窗体组件的方法
作者:小萝莉 时间:2023-04-24 11:47:57
本文实例讲述了C#中WPF使用多线程调用窗体组件的方法。分享给大家供大家参考。具体如下:
Thread thread=new Thread(new ThreadStart(TestThread));
thread.Start();
private void TestThread()
{
for (int i = 0; i < 11;i++ )
{
Thread.Sleep(2000);
this.listBox1.Dispatcher.Invoke(new Action(() => { this.listBox1.Items.Add("this is a test!!!"); }));
}
}
希望本文所述对大家的C#程序设计有所帮助。
标签:C#,WPF,多线程
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
java中TestNG使用教程详解
2021-11-29 12:53:55
![](https://img.aspxhome.com/file/2023/7/115907_0s.png)
C# 多线程编程技术基础知识入门
2023-05-27 08:00:24
RabbitMQ开启SSL与SpringBoot连接测试的配置方法
2023-09-25 14:40:30
![](https://img.aspxhome.com/file/2023/1/67671_0s.png)
Java回调函数与观察者模式实例代码
2023-11-16 17:30:11
C#中使用split分割字符串的几种方法小结
2023-06-18 17:23:21
全面解析Android之ANR日志
2023-12-18 23:30:21
![](https://img.aspxhome.com/file/2023/3/138103_0s.png)
如何将默认的maven仓库改为阿里的maven仓库
2022-09-30 14:16:31
![](https://img.aspxhome.com/file/2023/6/61526_0s.png)
C# 获取当前年份的周期及周期所在日期范围(推荐)
2021-10-06 15:00:44
![](https://img.aspxhome.com/file/2023/1/66131_0s.png)
Java 入门图形用户界面设计之单选按钮
2023-08-29 13:40:02
![](https://img.aspxhome.com/file/2023/2/108362_0s.png)
一篇文章带你入门Java修饰符
2021-12-25 12:46:01
![](https://img.aspxhome.com/file/2023/7/76597_0s.png)
Java判断所给年份是平年还是闰年
2023-10-21 17:48:59
Java实现贪吃蛇游戏(1小时学会)
2023-06-29 00:54:02
![](https://img.aspxhome.com/file/2023/4/75704_0s.jpg)
SpringBoot 监控管理模块actuator没有权限的问题解决方法
2022-01-26 21:50:11
C# winform循环播放多个视频
2021-06-30 06:39:21
解析maven的用法和几个常用的命令(推荐)
2022-04-16 23:31:15
![](https://img.aspxhome.com/file/2023/4/87174_0s.jpg)
Java并发编程之volatile与JMM多线程内存模型
2023-10-19 12:13:48
![](https://img.aspxhome.com/file/2023/3/62203_0s.png)
Java实现简单的抽牌游戏
2022-10-06 11:55:01
Java开发工具IntelliJ IDEA安装图解
2022-06-14 02:30:20
![](https://img.aspxhome.com/file/2023/4/69934_0s.png)
Spring Cloud Sleuth整合zipkin过程解析
2022-04-26 23:32:57
![](https://img.aspxhome.com/file/2023/5/129135_0s.jpg)
Intellij IDEA 2017新特性之Spring Boot相关特征介绍
2023-06-22 15:13:02
![](https://img.aspxhome.com/file/2023/0/88140_0s.gif)