标签需要很长时间才能改变 [英] Label takes long time to change

查看:33
本文介绍了标签需要很长时间才能改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 C# 中的 winform 应用程序有问题.在程序中,我有一个标签作为状态栏和一个这样的方法:

I have a problem with my winform app in C#. In program, i have a label as statusbar and a method like this:

private void btnProcess_Click(object sender, EventArgs e)
{
    lblStatus.Text = "Please wait...";
    /*
    Code here
    */
}

我的代码处理需要几秒钟,但在处理代码后,标签的文本会发生变化,我希望它在此之前发生.

my code process taking a few second but after processing the code, text of label will change and i want it happening before that.

注意:我是编程的业余爱好者,我不太懂英语,请简单解释一下您的解决方案.谢谢.

Note: I am an amateur in programming and i cant understand english very well, please explain your solution simply. thank you.

推荐答案

您可以通过调用 Update 或 Refresh 使用重绘事件来解决这个问题,但真正的解决方案是使用 BackgroundWorker 进行更长时间的操作.

You may be able to hack this using a repaint event by calling Update or Refresh, but the real solution is using a BackgroundWorker for longer operations.

这不是一件容易的事情,您应该找到一个用您完全理解的语言编写的教程.

This is not easy stuff, you should find a tutorial for it in a language you understand perfectly.

这篇关于标签需要很长时间才能改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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