Socket.Receive method. It blocks the UI
-
Hello. I'm using the socket class in an application and I use socket.receive to wait for data. The problem is that the interface gets locked while the receive method is executing. I want to see the interface so the user knows what's happening at any time. Is that possible?
Regards, Diego F.
-
Hello. I'm using the socket class in an application and I use socket.receive to wait for data. The problem is that the interface gets locked while the receive method is executing. I want to see the interface so the user knows what's happening at any time. Is that possible?
Regards, Diego F.
Hello, Put that socket code in diffrent thread..or it will block th UI until it receives the connection.. Regards :rose:, Nishu
-
Hello, Put that socket code in diffrent thread..or it will block th UI until it receives the connection.. Regards :rose:, Nishu
-
Youc can also use
BeginReceive
andEndReceive
to achieve the same. This moves the thread handling to the Socket class. If you are doing lots of operations then you might want to do the thread handling yourself.
Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
-
I found a problem with that. Now, I can't access the UI controls, as they are in other thread. I get an execution exception. How can I solve that?
Regards, Diego F.
You can use the
Invoke
method on the control or form to run the method you are calling on the correct thread.
Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
-
I found a problem with that. Now, I can't access the UI controls, as they are in other thread. I get an execution exception. How can I solve that?
Regards, Diego F.