I've been trying to figure out how to get my textbox's text or other property from within a background worker. Does anybody know how to do this? I cannot pass it as a param because it needs to be real-time. Thanks for the help!
I think you need to just invoke the property (pseudo-code):
private void bgw1_DoWork(object sender, DoWorkEventArgs e)
{
// looping through stuff
{
this.Invoke(new MethodInvoker(delegate { Text = textBox1.Text; }));
}
}
Use the ReportProgress method and event of the Background worker. That will switch to the correct thread for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With