如何在winforms中进行长时间操作时等待并显示忙碌动画 [英] How to Wait and display busy animation when doing long Operation in winforms

查看:77
本文介绍了如何在winforms中进行长时间操作时等待并显示忙碌动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试执行长度操作时尝试实现繁忙动画。



如何让屏幕变白并显示动画图标

I am trying to implement a Busy Animation when trying to perform a length operation.

how can i make screen white in color and show animation icon

推荐答案

使用单独的线程来显示简单的请等待消息是特别有用的,特别是如果您没有太多的线程经验。



更简单的方法是创建一个请等待表单,并在缓慢加载表单之前将其显示为无模式窗口。主表单加载完成后,隐藏请等待表单。



通过这种方式,您只使用一个主UI线程首先显示请等待表单和然后加载你的主表单。



这种方法的唯一限制是你的请等待表单不能动画(如动画GIF),因为线程正忙着加载你的主要表格。



Using a separate thread to display a simple please wait message is overkill especially if you don''t have much experience with threading.

A much simpler approach is to create a "Please wait" form and display it as a mode-less window just before the slow loading form. Once the main form has finished loading, hide the please wait form.

In this way you are using just the one main UI thread to firstly display the please wait form and then load your main form.

The only limitation to this approach is that your please wait form cannot be animated (such as a animated GIF) because the thread is busy loading your main form.

PleaseWaitForm pleaseWait=new PleaseWaitForm ();

// Display form modelessly
pleaseWait.Show();

//  ALlow main UI thread to properly display please wait form.
Application.DoEvents();

// Show or load the main form.
mainForm.ShowDialog();







请试试这个




Please Try This


这篇关于如何在winforms中进行长时间操作时等待并显示忙碌动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆