c# 多线程委托传参方式

 

1.定义一个线程调用的方法函数

private void RTPServer(object _Serverip)
{
IPEndPoint Serverip = _Serverip as IPEndPoint;

}

2.Thread _ReceiveThread ;//创建一个线程实例

3.调用函数

private void button4_Click(object sender, EventArgs e)
{
IPAddress ipaddress = IPAddress.Parse(txtIP.Text);
IPEndPoint ip = new IPEndPoint(ipaddress, 12006);

_ReceiveThread = new Thread(new ThreadStart(delegate { RTPServer(ip); }));
_ReceiveThread.IsBackground = true;
_ReceiveThread.Priority = ThreadPriority.AboveNormal;
_ReceiveThread.Start();

}

 

posted on 2019-04-09 10:31  Innershar  阅读(454)  评论(0编辑  收藏  举报

导航