“Cross-thread operation not valid” exception on inner controls

前端 未结 7 1504
南方客
南方客 2020-12-19 05:36

I\'ve been struggling with this for quite a while: I have a function designed to add control to a panel with cross-thread handling, the problem is that though the panel and

7条回答
  •  忘掉有多难
    2020-12-19 06:19

    In your own answer you state:

    To clarify things: "panel" is created on the base thread and "ctrl" on the new thread

    I think this might be the cause of your problem. All UI elements should be created on the same thread (the base one). If you need to create "ctrl" as a consequence of some action in the new thread, then fire an event back to the base thread and do the creation there.

提交回复
热议问题