I need to invoke a C dll as a background process. The execution of the dll is time-taking and therefore I want to show a progress bar on the main GUI. In order to use ReportProgress, I need to be able pass two arguments by reference and update the progress bar whenever the values of the arguments change. However, RunWorkerAsync only seems to take values (not references).
How can I do it?
Thanks.
Here is the simplified code:
public void button1_Click(object sender, EventArgs e)
{
//Variable declarations and initializations
List<object> arguments = new List<object>();
arguments.Add(curgen);
arguments.Add(dataindex);
backgroundWorker1.RunWorkerAsync(arguments);
backgroundWorker1.ReportProgress(curgen * 100 / ngen, "GEN");
backgroundWorker1.ReportProgress(dataindex * 100 / (DIMENSION * FITNESSCASES), "DATA");
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
List<object> genericlist = e.Argument as List<object>;
// Getting variables from object
calldll.gpinnovization(ref curgen, ref dataindex);
}
I want to pass 'curgen' and 'dataindex' by reference.