Possible to construct form on background thread, then display on UI thread

后端 未结 6 1531
情话喂你
情话喂你 2020-12-10 04:10

UPDATE: Just to summarize what my question has boiled down to:

I was hoping that constructing .NET forms and controls did NOT create any window handles -- hoping tha

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-10 04:38

    I think your understanding is a little off. Controls must be touched from the thread that created them, not the main UI thread. You could have numerous UI threads in a application, each with its own set of controls. Thus creating a control on a different thread will not allow you to work with it from the main thread without marshalling all of the calls over using Invoke or BeginInvoke.

    EDIT Some references for multiple UI threads:

    MSDN on Message Loops MSDN social discussion Multiple threads in WPF

提交回复
热议问题