I have downloaded a client server chat-type application that accompanies a tutorial. It was written in c#.net 2003, i have .net 2005.

There are two projects, client side and a server side.

It converted both the projects successfully, but when i try to run the projects it highlights the following line of code in the server side app, and says the thread has made an "unsafe call to a windows form control". I use the help, but am completely confused about what to do.

Please someone help!

ok, here is the line of code it highlights:

txtDataRx.Text = txtDataRx.Text + szData;

here are the surrounding lines of code:

{
CSocketPacket theSockId = (CSocketPacket)asyn.AsyncState ;
//end receive...
int iRx = 0 ;
iRx = theSockId.thisSocket.EndReceive (asyn);
char[] chars = new char[iRx + 1];
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
System.String szData = new System.String(chars);
txtDataRx.Text = txtDataRx.Text + szData; //this is the line
WaitForData(m_socWorker );
}

here is the relevant extracted section from the help:

// This event handler creates a thread that calls a
// Windows Forms control in a thread-safe way.
private void setTextSafeBtn_Click(
object sender,
EventArgs e)
{
this.demoThread =
new Thread(new ThreadStart(this.ThreadProcSafe));

this.demoThread.Start();
}

// This method is executed on the worker thread and makes
// a thread-safe call on the TextBox control.
private void ThreadProcSafe()
{
this.SetText("This text was set safely.");
}

I have just started this network c# programming, and that is y i am confused about what to do!

Any help would be greatly appreciated.

GTJ

ps. should this thread go into the network programming forum instead??

ps.Should i attach the projects to this thread so u can all experience the problem??