C # how to load form with marquee runtime ball?

I created a loadForm with only a progress bar with the marquee type. In my mainForm, I'm trying to do this:

//before downloading
loadingForm lf = new loadingForm();
lf.Show();
//start downloading
//finishdownloading
lf.Close();

A download file was displayed, but the progress bar did not appear, and the form looked as if it was a failure. after the download was complete, loadForm was closed and my application continued to work normally. In loadForm, I only have:

void loadingForm_Load(object sender, EventArgs e)
{
     progressbar1.visible = true;
}

I already set the progressbar1 style to highlight in loadForm.design. How to fix it? Thanks for your help in advance.

+3
source share
3 answers

, , , . BackgroundWorker , .

+1

There may not be “resources” in the user interface stream for redrawing ui, you must use a background worker, as mentioned, or process application messages in a queue. From the Show () method to the Close () method, you must definitely call Application.DoEvents (), so all Windows messages will be processed (along with redrawing the messages in your application form).

0
source

Source: https://habr.com/ru/post/1781442/


All Articles