I’m trying to read the values of the controls from a backgroundworker.
There are plenty of examples of how to update a control from a background thread, but i’ve not been able to find one example of how to read from it.
At the moment I have created a struct to pass to the backgroundworker, but it does not seem very elegant.
Struct:
public struct Arguments
{
public string version;
public bool isChecked;
public Arguments(string Version, bool IsChecked)
{
version = Version;
isChecked = IsChecked;
}
}
Button Click Event
Arguments pass = new Arguments(Version.Text.Trim(), (bool)Credentials.IsChecked);
export.RunWorkerAsync(pass);
DoWork Event
ExportSolution export = new ExportSolution(this, messageBox);
Arguments pass = (Arguments)e.Argument;
export.Export(pass.version, pass.isChecked);
This works fine, but I would like to do the following or something similar
DoWork event
ExportSolution export = new ExportSolution(this, messageBox);
export.Export(Access Version.Text.Trim() from here, ditto (bool)Credentials.IsChecked);
TIA
This is what I’ve ended up doing:
Where Version is a textbox and Credentials is a Checkbox.