private void 机器人坐标ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.dataGridView1.SelectedRows.Count == 1) { Task.Run(() => { var robot = new TsRemoteS(); robot.SetIPaddr(0, this.IpAddress, this.Port); robot.Connect(1); TsPointS p = robot.GetPsnFbkWorld(); DataGridViewRow dr = this.dataGridView1.SelectedRows.OfType <DataGridViewRow>().Single(); this.CalData.Rows[dr.Index]["x"] = p.X; this.CalData.Rows[dr.Index]["y"] = p.Y; this.CalData.Rows[dr.Index]["z"] = p.Z; Task.Run(() => { robot.Disconnect(); robot.Dispose(); }); }); } }