且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

<呼叫线程必须是STA,因为许多UI组件都需要STA.WPF

更新时间:2023-02-21 09:45:26

已解决,多亏了拉法尔(Rafal)的帖子:

Solved, thanks to Rafal's post:

问题在于,正在创建新MyParticipant的线程被默认设置为MTA,因此在MyParticipant内部,MTA线程正在调用新的VideoRenderer,该继承了Image.构造UI控件的MTA线程会导致此异常.

The problem is that the thread that was creating a new MyParticipant was being default set to MTA, and so inside MyParticipant, that MTA thread was calling new VideoRenderer, which inherits an Image. An MTA thread constructing a UI control results in this exception.