I have an windows form app with a textbox. In a second class I have a socket server and client connection. The idea is when a connection is made to the server port the network stream is sent on through the client to a destination port. I would like to display this data (an xml message) along with any responses in the text box in my form. After searching it seems I need to use a delegate pointing to a method which will update the textbox. In my form I have created the method:
public void update_txtBox(string data)
In the socket class I get the network stream and send it to the destination port but am struggling to write the data to the textbox.
public delegate void AddText(string data);
AddText updateTextBox = new AddText(Form1.update_txtBox);
Am I on the right track?
Do I declare the delegate in the form class or the socket class or either?
In which class do I declare the delegate variable and is my attempt above correct? (it doesn't work so probably not :)
Any help or a pointer to a good tutorial/explanation will be appreciated.