-1

I'm attempting to make a program to control the basic functions of a computer through a server/client method. I just need to send a string from the server to the client and vice versa. Every example I've found is really old and no longer works, or is poorly explained, or is in C#.

I almost have a working example as is, but I'm running into a threading issue where it won't let me modify elements in the UI after I've opened my thread for the connection from server to client or client to server. No idea how to fix this and I'm out of options.

Essentially I need a method of sending text from one IP/port to another in a server/client architecture.

Postman
  • 517
  • 2
  • 8
  • 17

1 Answers1

0

The clue to solving your issue is probably here: "I almost have a working example as is, but I'm running into a threading issue where it won't let me modify elements in the UI after I've opened my thread for the connection from server to client or client to server."

You cannot access controls (UI elements) created on one thread directly from another thread. So if you have another thread and you want to update an element in the UI, you need to use the Control.BeginInvoke Method.

You didn't post any code, so I won't try and give you an example that may be utterly useless in your case, but there's a good article on MSDN here - How to: Make Thread-Safe Calls to Windows Forms Controls. This is for Windows Forms, nut the principals are the same for any application.

Tim
  • 28,212
  • 8
  • 63
  • 76
  • So I wrote a very skeleton framework of my UDPclient code. It's not working now and I'm not sure why. Source Code(Press File>download) https://docs.google.com/file/d/0B2sn5IyNeCIESUV4cE91Sm81Vzg/edit?usp=sharing – Postman Apr 22 '13 at 04:54