Multiple UI Threads - Winforms

后端 未结 3 1574
无人及你
无人及你 2020-12-02 01:55

I want to create multiple UI threads in my application. I have simulated the scenario as below. I am creating a new window / form on a button click in a background

3条回答
  •  感情败类
    2020-12-02 02:29

    I think you will need to set the apartment state of your thread to single threaded as indicated here ApartmentState for dummies and here Thread-safe Form.Show: t.SetApartmentState(ApartmentState.STA). I don't know if that's possible on a background thread though.

    Another thing that I would urge you to look at is MDI (multiple document interface, e.g. here). Do you really need different forms display as an own window or are they rather documents inside a common form? You may have of course a reason to create multiple UI threads.

提交回复
热议问题