NET框架的所见即所得进度环(C#) [英] WYSIWYG Progress Circle for .NET Framework (C#)
本文介绍了NET框架的所见即所得进度环(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Application.DoEvents();
语句立即显示进度圈,但在长时间运行任务时不会旋转.
请帮忙,我不知道我在做什么错.
我的示例代码:
Application.DoEvents();
statement shows the Progress circle immediately but it does not spin while long task is running.
Please help, I can''t figure out what I am doing wrong.
My sample code:
private void btnFindFileAndLoad_Click(object sender, EventArgs e)
{
this.progressCircle1.Visible = true;
this.progressCircle1.Rotate = true;
Application.DoEvents(); //process message queue
LoadMyFile(str_FileDirectory_and_FileName); //runs for 20sec
this.progressCircle1.Visible = false;
this.progressCircle1.Rotate = false;
}
推荐答案
这是因为它在同一线程上.您需要在后台线程上运行进度圈或在后台线程上加载文件,并在后台线程完成后关闭进度圈.
It''s because it''s on the same thread. You need to run the progress circle on a background thread or load the file on a background thread and turn off the progress circle when the background thread completes.
这篇关于NET框架的所见即所得进度环(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文