Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Chat Application with TextBox

0 views
Skip to first unread message

Gonzalo

unread,
Nov 10, 2009, 10:20:24 PM11/10/09
to
Hi all,

I have a chat application in Windows CE 6.0 with 2 TextBox, one TextBox to
write the frame to send an the other one to write the frames sent and
received.

When I send a frame, I write it in the TextBox.

private void ButtonSend_Click(object sender, EventArgs e)
{
if (TextBoxSend.Text != "")
MyXBeeDevice.Transmit(TextBoxSend.Text);
TextBoxLog.Text += "-> " + TextBoxSend.Text + "\r\n";
TextBoxSend.Text = "";
TextBoxSend.Focus();
}

However, when I receive a frame, I can't write it in the TextBox, I have an
Exception.

private void PacketReceived(XBeeDevice sender, byte[] ReceivedData)
{
TextBoxLog.Text += "<- " +
InternalEncoding.GetString(ReceivedData, 0, (int)ReceivedData.Length) +
"\r\n";
}

I have tried write a string in the TextBox e.g.("Hello World") and I have
the same Exception. Does anyone know what is the problem?

Thank you .

Paul G. Tobey [eMVP]

unread,
Nov 11, 2009, 12:07:35 AM11/11/09
to
You can't asynchronously perform operations to GUI objects. The button
click is NOT asynchronous, because a user interface operation, the click,
triggered the event. However, it should be clear that a serial port event
is totally asynchronous with the GUI, so you have to use Invoke() to do
anything to a control, window, etc. from the serial event handler.

Paul T.

"Gonzalo" <Gon...@discussions.microsoft.com> wrote in message
news:A99AD80E-7979-41A8...@microsoft.com...

0 new messages