We just spent 300 man-hours fixing a buggy application in the field. It all came down to calling Application.DoEvents (re-entrancy problem).
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.
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.
What do you suggest to prevent this issue from happening again:
- Add checkin gates to source control?
- Developer training?
- Code Analysis rules (why is this not already a built-in rule?)
How to I enforce a coding practice?
Every time the application is built centrally, run this on every assembly:
Then search the output for:
If it’s found, mark the build as failed, as if it was a compile error.