问题描述
我创建了一个loadingForm,只有一个带有选取框样式的进度条.在我的 mainForm 我试图这样做:
I created a loadingForm with only a progress bar with marquee style. In my mainForm I'm trying to do this:
//before downloading
loadingForm lf = new loadingForm();
lf.Show();
//start downloading
//finishdownloading
lf.Close();
loadingForm 显示了但是进度条没有出现,并且表单看起来像是崩溃了.下载完成后,loadingForm 关闭,我的应用程序继续正常运行.在 loadingForm 我只有:
The loadingForm was shown but the progress bar didn't appear, and the form looked like it was crash. after finishing downloading, the loadingForm was closed and my app continued to run normally. In loadingForm I only have:
void loadingForm_Load(object sender, EventArgs e)
{
progressbar1.visible = true;
}
我已经在 loadingForm.design 中将 progressbar1 样式设置为选取框.我该如何解决?提前感谢您的帮助.
I already set progressbar1 style to marquee in loadingForm.design. How do I fix this? thanks for your help in advance.
推荐答案
你应该看看使用 BackgroundWorker Class 用于耗时的操作,以便 UI 可以在后台工作线程完成工作的同时继续显示进度.
You should have a look at using BackgroundWorker Class for the time consuming actions, so that the UI can continue showing the progress while the background worker thread does the work.
这篇关于C#如何加载带有选取框进度条的表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!