Kernowmarplek
Programmer
I am building an application that sends and receives data from a laser coder. I am using multi-threading and would like to send the received string to a text box on the only form, however, the thread is unable to see the form.
For the code
static void ReadResponseThread()
{
StreamReader sr = new StreamReader(ss,System.Text.Encoding.ASCII);
try
{
for (;
{
string response = sr.ReadLine();
if (response != ""
{
txtBox1.Text = response;
}
}
}
catch(ThreadAbortException)
{
}
}
I get the following error
An object reference is required for the nonstatic field, method, or property 'WindowsSerial2.Form1.txtBox1'
Anybody know what's going on?
For the code
static void ReadResponseThread()
{
StreamReader sr = new StreamReader(ss,System.Text.Encoding.ASCII);
try
{
for (;
{
string response = sr.ReadLine();
if (response != ""
{
txtBox1.Text = response;
}
}
}
catch(ThreadAbortException)
{
}
}
I get the following error
An object reference is required for the nonstatic field, method, or property 'WindowsSerial2.Form1.txtBox1'
Anybody know what's going on?