****
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 线程多次调用
{
public partial class Form1 : Form
{
string m_aca;
public Form1()
{
InitializeComponent();
timer1.Interval = 100;//单位mS
timer1.Start();
}
private void button1_Click(object sender, EventArgs e)
{
var t1 = new Task(() => TaskMethod(textBox1.Text));
t1.Start();
Task.WaitAll(t1);//等待所有任务结束
}
void TaskMethod(string ddd)//线程的函数
{
m_aca = ddd;
}
private void timer1_Tick(object sender, EventArgs e)
{
textBox2.Text = m_aca;
}
}
}
运行效果
在textBox1 里面写入的String 内容,
然后按下按钮
然后 就会在textBox2 显示同样的内容
***
大致解释一下