UI线程安全
关于更改表单控件属性时确保线程安全的最佳方法有什么建议吗? 我一直在使用我。 调用过去,我想知道您是否有优点/缺点、意见、建议等。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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.
如果您从另一个线程向表单推送内容,则调用是正确的方法。
但是您可能会考虑表单是否可以更好地从计时器中提取数据本身,并且可能比后台进程推送单独更新的频率更低。
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.