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

前端 未结 7 1491
南方客
南方客 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:18

    Where is pnlFoo being created, and in which thread? Do you know when its handle is being created? If it's being created in the original (non-UI) thread, that's the problem.

    All control handles in the same window should be created and accessed on the same thread. At that point, you shouldn't need two checks for whether Invoke is required, because ctrl and panel should be using the same thread.

    If this doesn't help, please provide a short but complete program to demonstrate the problem.

提交回复
热议问题