调用另一个form显示出来就没有了响应
程序思想如下:
------------------------------
原来的程序
------------------------------
Form Load时创建一个新的进程并且开始执行
这个进程所执行的Listen的内容如下:
监听从端口tcpPort接收到的信息,可以成功
我想设置成每接受一条消息就显示另外一个Form
所以程序就改成了
可是这里这个floatform显示出来就没有了响应
是floatform没有响应,不是主程序没有响应
这是为什么呢?
------------------------------
原来的程序
------------------------------
Form Load时创建一个新的进程并且开始执行
listenerRun = true;
thread = new Thread(new ThreadStart(Listen));
thread.Start();
thread = new Thread(new ThreadStart(Listen));
thread.Start();
这个进程所执行的Listen的内容如下:
private void Listen()
{
try
{
tcpl = new TcpListener(tcpPort);
tcpl.Start();
while(listenerRun)
{
Socket s = tcpl.AcceptSocket();
Byte[] strem = new byte[80];
int i = s.Receive(strem);
string message = System.Text.Encoding.UTF8.GetString(strem);
TBContent.AppendText(message);
Thread floatThread = new Thread(new ThreadStart(ShowFloat));
floatThread.Start();
}
}
catch(System.Security.SecurityException)
{
MessageBox.Show("防火墙安全错误","Error",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
}
{
try
{
tcpl = new TcpListener(tcpPort);
tcpl.Start();
while(listenerRun)
{
Socket s = tcpl.AcceptSocket();
Byte[] strem = new byte[80];
int i = s.Receive(strem);
string message = System.Text.Encoding.UTF8.GetString(strem);
TBContent.AppendText(message);
Thread floatThread = new Thread(new ThreadStart(ShowFloat));
floatThread.Start();
}
}
catch(System.Security.SecurityException)
{
MessageBox.Show("防火墙安全错误","Error",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
}
监听从端口tcpPort接收到的信息,可以成功
我想设置成每接受一条消息就显示另外一个Form
所以程序就改成了
while(listenerRun)
{
Socket s = tcpl.AcceptSocket();
Byte[] strem = new byte[80];
int i = s.Receive(strem);
string message = System.Text.Encoding.UTF8.GetString(strem);
TBContent.AppendText(message);
FloatForm floatform = new FloatForm();
floatform.Show();
}
{
Socket s = tcpl.AcceptSocket();
Byte[] strem = new byte[80];
int i = s.Receive(strem);
string message = System.Text.Encoding.UTF8.GetString(strem);
TBContent.AppendText(message);
FloatForm floatform = new FloatForm();
floatform.Show();
}
可是这里这个floatform显示出来就没有了响应
是floatform没有响应,不是主程序没有响应
这是为什么呢?