WinForms interthread modification

前端 未结 4 1810
傲寒
傲寒 2020-12-21 13:46

Whenever I want to modify a winform from another thread, I need to use

->Invoke(delegate, params)

so that the modification occurs in the winf

4条回答
  •  萌比男神i
    2020-12-21 13:54

    I recall turning off the checks and manually verifying that every call I used was safe.

    A surprising number of them could be called cross-threaded because of the guarantee I had about where certain threads were (semaphores) or because they called underlying API functions that could be used on other processes.

    I still ended up with lots of invokes, usually on context objects so I could MethodInvoker.

    I also encountered a nasty bug in Control.Invoke, driving me to write a custom invoker library.

提交回复
热议问题