ParameterizedThreadStart,ThreadStart的使用,线程Thread传参数
2024-10-20 03:57:45
Thread
threadWithParam = new Thread(new ParameterizedThreadStart(new ThreadTest().ShowMsg));//threadWithParam.Start("this is a param.");
threadWithParam.Start(
thread.Start();
"44444");Thread thread=new Thread(new ThreadStart(new Class11().ShowMsg));
表示在 Thread 上执行的方法的委托方法,ThreadStart不能带参数,ParameterizedThreadStart是2.0中新增的,可以带参数(object类型的)
using System.Threading;
public void ShowMsg()
{
MessageBox.Show("Message Info.");
}
Thread thread = new Thread(new ThreadStart(ShowMsg));
thread.Start();
//带参数
public void ShowMsg(object msg)
{
MessageBox.Show(msg.ToString());
}
Thread threadWithParam = new Thread(new ParameterizedThreadStart(new ThreadTest().ShowMsg));
threadWithParam.Start("this is a param.");
最新文章
- 移动端开发概览【webview和touch事件】
- MongoDB学习笔记(一:常见问题汇总)
- haproxy 实现多域名证书https
- android 多线程 示例
- WORDPRESS 后台500错误解决方法集合
- C++沉思录之二——虚函数使用的时机
- linux网络编程:select()函数以及FD_ZERO、FD_SET、FD_CLR、FD_ISSET(转)
- 《SpringMVC数据绑定入门》笔记
- android相对布局中控件的常用属性【转】
- 判断是否为JSON对象
- 2018-2019-2 20189206 Python3学习
- uWSGI和Gunicorn
- 深度学习原理与框架-Tensorflow基本操作-Tensorflow中的变量
- docker基础:dockerfile的介绍
- 第六章 图(b1)邻接矩阵
- hdu-1150(二分图+匈牙利算法)
- java分布式系统开关功能设计(服务升降级)
- UOJ #164 【清华集训2015】 V
- leetcode difficulty and frequency distribution chart
- F4NNIU 版本的标准电阻列表(2018-09-29 更新)