How do I update a Label from within a BackgroundWorker thread?

后端 未结 5 1941
慢半拍i
慢半拍i 2020-12-20 06:59

When I used WinForms, I would have done this in my bg_DoWork method:

status.Invoke(new Action(() => { status.Content = e.ToString(); }));
sta         


        
5条回答
  •  孤城傲影
    2020-12-20 07:38

    You need to use

    Dispatcher.Invoke(new Action(() => { status.Content = e.ToString(); }))

    instead of status.Invoke(...)

提交回复
热议问题