G
Guest
I'm just getting familiar with Visual Studio and C#. I want to start a
thread that monitors a serial port and sends what comes across to a text box
on the main screen. So, I create a thread to do that at the push of a
button. However, when something comes in on the serial port, the program
bombs because it says that I am trying to access a component (namely, the
textBox) that was created in another thread. I tried calling
Monitor.Enter(textBox1) and Monitor.Exit(textBox1) before and after the
textBox1.Text = ... call, but still get the same error. Can someone give me
a tiny example of how to access a component on the main form from within a
thread?
Thanks,
Don
thread that monitors a serial port and sends what comes across to a text box
on the main screen. So, I create a thread to do that at the push of a
button. However, when something comes in on the serial port, the program
bombs because it says that I am trying to access a component (namely, the
textBox) that was created in another thread. I tried calling
Monitor.Enter(textBox1) and Monitor.Exit(textBox1) before and after the
textBox1.Text = ... call, but still get the same error. Can someone give me
a tiny example of how to access a component on the main form from within a
thread?
Thanks,
Don