问题
Any suggestions on the best way to ensure thread safety when changing the properties on Form controls? I have been using Me. Invoke in the past, and I was wondering if you have pros/cons, comments, suggestions, etc.
回答1:
Invoke is the proper way to do it if you're pushing stuff at the form from another thread.
But you might consider whether the form might be better pulling data itself, perhaps from a timer, and perhaps less frequently than a background process might push individual updates.
回答2:
I do control. Invoke on the target control rather than the entire form, but that's just me. I claim no advanced knowledge of win forms, I just have to use it every now and then.
来源:https://stackoverflow.com/questions/56886/ui-thread-safety