So, I have one class that launches a new class in a new background worker, and the background worker sends status messages back using the progresschanged section.
When I try and use this by typing
classname.Dataworker.reportprogress(5)
from a separate class, I get an error that I am using an object before the definition.
In the examples I found, everyone uses the same class and different functions inside this.
It might be a silly easy mistake, but I just can't see it, thanks for any help you can give!
General overview of my code:
public static BackgroundWorker bw = new BackgroundWorker();
onbuttonclick
{
installer install = new installer();
bw.WorkerReportsProgress = true;
bw.WorkerSupportsCancellation = true;
bw.DoWork += class2.aFunction;
bw.ProgressChanged += new ProgressChangedEventHandler(mainForm_InstallerEvent);
bw.RunWorkerAsync();
}
private void mainForm_InstallerEvent(object sender, ProgressChangedEventArgs e)
{
lbl.Text = e.UserState.ToString();
}
//// class2 class of the working class
aFunction
{
InstallerForm.bw.ReportProgress(5); //errors on this!
}
source
share