So I have a program that works as the UI for a console app. I tried to add a progress bar to it. When the user clicks on the Start
button, it does this:
MainProgress.Value = 0;
MainProgress.Maximum = PackageNwCheckbox.IsChecked == true ? 4 : 3;
BackgroundWorker compilerWorker = new BackgroundWorker();
compilerWorker.WorkerReportsProgress = true;
compilerWorker.DoWork += StartCompiler;
compilerWorker.ProgressChanged += CompilerReport;
compilerWorker.RunWorkerAsync();
This is in order to update the progress bar when the GUI program works and feeds the console program. When the program starts populating the array called filemap
like this:
filemap = Directory.GetFiles(ProjectLocation.Text + "\\www\\js\\", "*.js");
//The variable is an array of strings.
The app crashes and the error says
The call thread couldn't access the item because another thread has it.