C# 多线程无参/带参执行方法

private void button1_Click(object sender, EventArgs e)
{
	//无参方式一
	Thread thread = new Thread(display);
	thread.Start();
	
	//无参方式二
	Thread thread = new Thread(new ThreadStart(display));
	thread.Start();
	
	//带参方式一
	Thread thread = new Thread(display);
	thread.Start("Name");
	
	//带参方式二
	Thread thread = new Thread(new ThreadStart(delegate () { display("Name", age); }));
	thread.Start();
}

public void display()
{
	//这里是执行的代码
}

public void display(object Name)
{
	//这里是执行的代码
}

public void display(string Name,int age)
{
	//这里是执行的代码
}

原帖地址:https://www.whg6.com/219.html

0 0 投票数
文章评分
0 评论
内联反馈
查看所有评论
0
本文贡献者正期待您发表意见x
滚动至顶部