c# - 立即更新 toolStripStatusLabel

标签 c# multithreading statusstrip toolstripstatuslabel

我有一个 WinForms 程序,它有一个 button、一个 statusStrip 和一个 toolStripStatusLabel 在那个 statusStrip .如果我点击按钮并运行:

private void button1_Click(object sender, EventArgs e)
{
    toolStripStatusLabel1.Text = "Test";

    System.Threading.Thread.Sleep(5000);
}

然后 toolStripStatusLabel 的文本直到线程完成休眠后才会更新。我如何让它立即更新,然后让线程休眠?

最佳答案

作为P. Kouvarakis说,解决方案是这样的:

toolStripStatusLabel1.Text = "Test";
statusStrip1.Update();

关于c# - 立即更新 toolStripStatusLabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43460212/

相关文章:

c# - 在 WinForms 中为 StatusStrip 中的文本着色

c# - 如何从 "Grip"回收空间

c# - 使用 c# 从 Azure 存储帐户表检索记录,同时使用 xamarin 开发跨平台应用程序给出错误

c# - 接口(interface)或 switch 语句,找到正确的模式

c# - 将 SqlDataReader 用作资源的习惯用法

java - JVM后台运行什么

vb.net - 如何从 VB.NET 中的 StatusStrip 中删除 'resize triangle'

c# - 在 Linq 中子查询的有效方法

c - 细粒度多线程——一个工作任务应该做多少事情?

java - 同步静态方法在 Java 中是如何工作的,我可以用它来加载 Hibernate 实体吗?