Task.Run( new Action (() => { GetPLCValue();} ) ); 这个不知道是什么意思?
F羊 2021-03-02 01:51:12 下面有一段代码,其中一个不知道是什么意思, Task.Run( new Action (() => { GetPLCValue();} ) );
不知道这个知道点在哪里查找。我看了不像是 lambda表达式.
private void button1_Click(object sender, EventArgs e)
{
if (this.button1.Text == "连接")
{
//实例化socket
tcpClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
//IP4,字节流,TCP
EndPoint EP = new IPEndPoint(IPAddress.Parse(this.txt_IP.Text), int.Parse(this.txt_Port.Text));
try
{
tcpClient.Connect(EP);
}
catch (Exception ex)
{
MessageBox.Show("连接失败:" + ex.Message);
return;
}
MessageBox.Show("连接成功");
this.button1.Text = "关闭";
Task.Run( new Action (() => { GetPLCValue();} ) ); ////就是这句??????????????
}
else
{
tcpClient?.Close();
this.button1.Text = "连接";
}
}