Note that there are some explanatory texts on larger screens.

plurals
  1. POProgress Bar in Background Worker not loading
    text
    copied!<p>I've run into an issue that I can't seem to figure out the solution to, I've read several answers and have gotten as far as knowing that I need a BackgroundWorker Thread to make this solution work, but I'm still running into a bit of an issue.</p> <p>I have a second form that is a small size and set to center on screen with a ProgressBar Style set to Marquee, there is nothing else on this second form as it is meant to emulate a loading bar.</p> <p>In my data intensive section of the code, on the main form, where it grabs and parses data from a database I have it written like this:</p> <pre><code> GetData() { bwLoading.RunWorkerAsync(); //Runs all the processing bwLoading.CancelAsync(); } </code></pre> <p>The background worker is defined as such below, also on the main form.</p> <pre><code> private void bwLoading_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; frmLoading lb = new frmLoading(); bool running = true; while (running) { if ((worker.CancellationPending == true)) { lb.Close(); running = false; } else { lb.Show(); } } } </code></pre> <p>The problem I have run into is that with this method it shows the Loading form that contains the progress bar does show up when the data starts getting gathered and process and does disappear when the data load is complete, but the window is empty like it's trying to load, but it doesn't. I can't seem to figure out why this isn't working.</p> <p>Isn't the background worker creating a separate thread for the Loading form to use? Or is there something else that I'm missing from my reading?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload