Hi all, I've written a server programme that accepts UDP packets from a client programme that I have also written... It's been working fine but recently I've started to get an exception...
Here is the the code that's causing the problem:
public delegate void AddnewText(string str);
public void AddTextToTextBox(string str)
{
if (this.tbCurrent.InvokeRequired)
{
this.Invoke(new AddnewText(AddTextToTextBox), str);
}
else
{
this.tbCurrent.Text += str;
}
}
When a packet comes in to the Server app, it's placed into a textbox called tbCurrent then the contents of that are sent to a textbox on the same form called displayTextBox (sorry about the awful naming conventions!)
The packet will be displayed in the displayTextBox meaning that the packet has successfully arrived, but for some reason I get an ObjectDisposedException informing me that I cannot write to a closed TextWriter...
Here is the method that I'm using to wait for packets to arrive:
public void WaitForPackets()
{
while (true)
{
byte[] data = client.Receive(ref receivePoint);
AddTextToTextBox(System.Text.Encoding.ASCII.GetString(data));
}
}
Is anyone familiar with this exception?