在加载过程中显示动画

Eyl*_*yla 2 c# winforms

好吧,我想要做的是显示一个动画gif,同时它读取一个充满文件的目录,但UI冻结,这是好的,但我想保持gif运行,直到操作完成.有任何想法吗?

我是在使用VS2010 C#的Windows窗体上进行的

HCL*_*HCL 5

下面是一些示例代码,您可以如何加载文件aysnchronous.也许它会帮助你.我比使用DoEvents更喜欢这种方式.使用DoEvents我已经有一些不良副作用,因此我尽量不使用它.

BackgroundWorker bgWorker = new BackgroundWorker() { WorkerReportsProgress=true}; 
bgWorker.DoWork += (s, e) => {     
    // Load here your file/s     
    // Use bgWorker.ReportProgress(); to report the current progress 
}; 
bgWorker.ProgressChanged+=(s,e)=>{     
    // Here you will be informed about progress and here it is save to change/show progress. You can access from here savely a ProgressBars or another control. 
}; 
bgWorker.RunWorkerCompleted += (s, e) => {     
// Here you will be informed if the job is done.
// Use this event to unlock your gui
}; 
bgWorker.RunWorkerAsync(); 
Run Code Online (Sandbox Code Playgroud)