Hello guys I have a question regardless a old code a client needed a update.
This code add a thread.sleep(500) to keep the service alive, is reading from a com port some calls, and sending a alarm to other pcs now this time when I was sending some information to the machine in question this error pops out
Cross-thread operation not valid: Control 'textBox1' accessed from a thread other than the thread it was created on.
    private void port_DataReceived(object sender, SerialDataReceivedEventArgs e) {
        Thread.Sleep(500);
        string data = port.ReadExisting();
        //try
        //{
            if (textBox1.TextLength == 30000)
            {
                textBox1.Text = "";
            }
        //}
        //catch (Exception) {}
        this.BeginInvoke(new setTextDeleg(si_DataRecived), new object[]{
        data});
    }
This is the funtion that writes on the com machine, does making a exception to eat the error is ok, or is there another better way to handle it?
PD: Sorry for my bad english, this is on C# 2008 vs