什么是从调用System.Windows.Forms.Application.DoEvents停止开发()的最佳方法是什么? [英] What is the best way to stop developers from calling System.Windows.Forms.Application.DoEvents()?
问题描述
我们只花了300个工时固定在该领域的越野车应用程序。这一切都归结为调用Application.DoEvents(重入性问题)。
We just spent 300 man-hours fixing a buggy application in the field. It all came down to calling Application.DoEvents (re-entrancy problem).
这不是陷入设计评审,code的评论。在code插入两年前的第一个版本;该应用程序总是酥,但最近的变化暴露了重入的问题更大程度。
This was not caught in design reviews, code reviews. The code was inserted two years ago with the first version; the application was always "flaky" but recent changes exposed the re-entrancy problems to a greater degree.
此事件已经是第二次在我们的组织,Application.DoEvents引起的故障和多工时调试。它是通过简单地注意到该呼叫发现在这种情况下,埋方式倒在一个复杂的事件处理程序异步任务
This incident is the second time in our organization that Application.DoEvents caused failures and multi-man hours of debugging. It was discovered in this case by simply noticing the call, buried way down in a complex event handler for an asynchronous task.
什么,你的再次发生建议prevent这个问题做的:
What do you suggest to prevent this issue from happening again:
- 添加签入大门,源代码管理?
- 在开发培训?
- code分析规则(为什么这是不是已经内置的规则?)
如何我执行编码的做法呢?
How to I enforce a coding practice?
推荐答案
每当应用程序建立统一处理,对每一个组件,运行此:
Every time the application is built centrally, run this on every assembly:
ildasm MyAssembly.exe /TEXT
然后搜索输出:
Then search the output for:
System.Windows.Forms.Application::DoEvents
如果它的发现,标志着建设为失败,就好像它是一个编译错误。
If it's found, mark the build as failed, as if it was a compile error.
这篇关于什么是从调用System.Windows.Forms.Application.DoEvents停止开发()的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!