try
{
port = Int32.Parse(textBox1.Text);
}
catch { MessageBox.Show("Please enter a number!"); }
try
{
listener = new TcpListener(port);
listener.Start();
Thread thread = new Thread(new ThreadStart(myThread));
thread.Start();
MessageBox.Show("设置成功!!");
}
catch (Exception ee) { MessageBox.Show(ee.Message); } public void receive()
{
try
{
socket = listener.AcceptSocket();//在这个位子程序就无响应 了 }
catch { return; } .......
public void myThread()
{
if (textBox2.InvokeRequired || textBox3.InvokeRequired)
Invoke(new myDel(receive)); //通过Invoke执行委托,从而去执行线程想要完成的任务 }帮忙求解哈,
{
port = Int32.Parse(textBox1.Text);
}
catch { MessageBox.Show("Please enter a number!"); }
try
{
listener = new TcpListener(port);
listener.Start();
Thread thread = new Thread(new ThreadStart(myThread));
thread.Start();
MessageBox.Show("设置成功!!");
}
catch (Exception ee) { MessageBox.Show(ee.Message); } public void receive()
{
try
{
socket = listener.AcceptSocket();//在这个位子程序就无响应 了 }
catch { return; } .......
public void myThread()
{
if (textBox2.InvokeRequired || textBox3.InvokeRequired)
Invoke(new myDel(receive)); //通过Invoke执行委托,从而去执行线程想要完成的任务 }帮忙求解哈,
解决方案 »
- C# winform窗体登录代码
- 多种方法 获取 COOKIE 都不完整.............
- 一个字符分析截取的问题
- 用C#怎样实现下面的功能呢?
- 大家觉得有必要对Web Service再次封状吗?
- 读取问题 急 在等 谢谢!
- 在C#中用什么流可以正常读word 文档
- 如何在DataGrid(Windows Form)的表格中加入ComboBox控件
- 那位大哥有C#的入门视频教程 介绍个 我是菜鸟 谢谢~!!!
- < 网页在线编辑器源码开放、免费 > ★ mEditor ASP 2.0 ★ (可用于ASP.Net)
- c# webBrowser 怎样取页面<table></table>中的内容
- 新手对于dbhelper的疑问
不加委托 线程直接 调用 receive()方法就不会出现 那情况。
listener.Start();
将上面的语句写到线程中
{
listener = new TcpListener(port);
listener.Start();
socket = listener.AcceptSocket();
}
catch { return; }这样了还是不行