Client/Server TCPClient
-
Hi, I developed an Client / Server application, the problem is the following: - when a wrong IP address is inserted in the Textbox, Client application freeze.
TcpClient socketForServer;
try
{
socketForServer = new TcpClient(Ip, Port);
}
catch (Exception e1) {
info._error = e1.ToString();
return info;
}What I can do?
-
Hi, I developed an Client / Server application, the problem is the following: - when a wrong IP address is inserted in the Textbox, Client application freeze.
TcpClient socketForServer;
try
{
socketForServer = new TcpClient(Ip, Port);
}
catch (Exception e1) {
info._error = e1.ToString();
return info;
}What I can do?
You will want to start running your TCPClient on a different Thread so it doesn't lock up the GUI thread while waiting for a timeout or connection refused. So do the following ThreadPool.QueueUserWorkItem(new WaitCallback()); Keep in mind that the Drawing of items can only be done on the thread they were created on (usually the main thread) so setting text and that sort of thing should be done by invoking the functions using the Invoke function
-
You will want to start running your TCPClient on a different Thread so it doesn't lock up the GUI thread while waiting for a timeout or connection refused. So do the following ThreadPool.QueueUserWorkItem(new WaitCallback()); Keep in mind that the Drawing of items can only be done on the thread they were created on (usually the main thread) so setting text and that sort of thing should be done by invoking the functions using the Invoke function
-
You will want to start running your TCPClient on a different Thread so it doesn't lock up the GUI thread while waiting for a timeout or connection refused. So do the following ThreadPool.QueueUserWorkItem(new WaitCallback()); Keep in mind that the Drawing of items can only be done on the thread they were created on (usually the main thread) so setting text and that sort of thing should be done by invoking the functions using the Invoke function
-
Hi, I developed an Client / Server application, the problem is the following: - when a wrong IP address is inserted in the Textbox, Client application freeze.
TcpClient socketForServer;
try
{
socketForServer = new TcpClient(Ip, Port);
}
catch (Exception e1) {
info._error = e1.ToString();
return info;
}What I can do?
there are couple of things that you may do 1. Application.DoEvents() 2. You need to set socketForServer to null in case an error occurs, it will be creating a new object every time and will become a source of memory leak.
Ahsan Ullah Senior Software Engineer MCTS 2.0