How can I update the value of a Label control periodically?

前端 未结 4 2035
别跟我提以往
别跟我提以往 2021-01-29 05:53

I\'m trying to make a label display some text, and then after a short while refresh itself and be able to re-display something else later. At the moment however I don\'t know ho

4条回答
  •  我在风中等你
    2021-01-29 06:31

    I would use another thread for it:

    labelWARNING.Visible = true;
    labelWarningMessage.Text = "This module has a prerequisite module: " + item;
    new Thread(() => {
        Thread.Sleep(5000);
        Dispatcher.BeginInvoke((Action)(() => { labelWARNING.Visible = false; }));
    }).Start();
    

    (this is for WPF, for WinForms should be essentially the same)

提交回复
热议问题