"An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
Additional information: Cross-thread operation not valid: Control 'txtIn' accessed from a thread other than the thread it was created on."
Here is the code I'm currently running:
private void Form1_Load(object sender, EventArgs e)
{
ThreadStart Watch = new ThreadStart(Monitor);
Thread thread = new Thread(Watch);
thread.Start();
}
public void Monitor()
{
int INF = 0;
while (INF <= 10)
{
txtIn.Text = INF.ToString();
Application.DoEvents();
Thread.Sleep(6000);
INF += 1;
}
}
This is all in the form class and the while loop will eventually be infinite and include polling the parallel port. So how can I gain access to the form objects from this separate thread? Thanks for any help.

New Topic/Question
Reply



MultiQuote



|