Recently I was dealing with a couple of bugs in C# regarding timeout behavior. The solutions were pretty interesting so I decided to share them. Consider these scenarios: We show a dialog to the user with some message. We close the dialog after 15 seconds. However, if the user closes the dialog manually, we have no need to close it at timeout. Start a long operation. If that operation lasts more than 5 seconds – Abort it.
A long time ago, on my first programming job I had a design problem that I couldn’t solve. This problem haunted me. The reason was that it seemed so simple, and yet I couldn’t find a good solution for it. Eventually I did a huge refactor, but instead of solving it correctly I simply changed one problem to another. Recently, years later, in a different company, I came up with that great solution I was after.