C# cross-thread call problem

前端 未结 3 1485
情书的邮戳
情书的邮戳 2020-12-16 09:07

I\'m writing a form app in c# and I need to be able to change the contents of a Rich Text Box from any thread, I tried using a delegate and InvokeRe

3条回答
  •  清歌不尽
    2020-12-16 09:10

    I mostly use this, and it works perfectly. For the exact same purpose are what you are intending.

    public void UpdateSub(string message)
    {
        subDisplay.subBox.Invoke((Action)delegate {
            subDisplay.subBox.Text = message;
        });
    }
    

    Hope it help's your or someone else with it!

提交回复
热议问题