i have an issue where i need to update text within a form run in a thread but cannot work how exactly this would be acheivable, here's my existing code:
public partial class Class1: Form
{
LoadText = loadText;
ResourceName = resourceName;
static private void ShowForm()
{
LoadForm = new Class1(LoadText, ResourceName);
Application.Run(LoadForm);
}
static public void ShowLoadScreen(string sText, string sResource)
{
LoadText = sText;
ResourceName = sResource;
Thread thread = new Thread(new ThreadStart(Class1.ShowForm));
thread.IsBackground = true;
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
}
Now i need to change the text in a textbox under the newly started form, this needs to be performed from the theoretical 'Class2':
class Class2
{
public void UpdateThreadFormTextbox
{
Class1.ShowLoadScreen("text", "text");
//Change textbox in the thread instance of Class1 form
}
}
I've looked into using 'Invoke' but i can't use that from Class2, does have a solution that will enable me to update the text in the Class1 thread instance from Class2?