Like varocarbas, any component that you put in your constructor throws a Cross thread exception.
to access the stream you need to use invke, beginInvoke.
try to run
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += (s1,e1) =>
{
textBoxt1.Text = "foo"; // Exception here
}
bw.RunWorkerCompleted += (1s, e1) =>
{
textBoxt1.Text = "foo"; // No exception here off UI thread
}
bw.RunWorkerAsync();
replace instead
bw.DoWork += (s1,e1) =>
{
this.Invoke((MethodInvoker) delegate
{
textBoxt1.Text = message;
}); // No Exception now
}
source
share