Textbox text from background worker?

后端 未结 4 1642
鱼传尺愫
鱼传尺愫 2021-01-13 14:14

I\'ve been trying to figure out how to get my textbox\'s text or other property from within a background worker. Does anybody know how to do this? I cannot pass it as a para

4条回答
  •  执念已碎
    2021-01-13 14:51

    Or if needed in WPF:

    private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
    {
        string text = null;
        myTextBox.Dispatcher.Invoke(new Action(delegate()
        {
            text = myTextBox.Text;
        }));
    }
    

提交回复
热议问题