Catch... When
Here is a tiny detail in the try/catch syntax of VB.NET you not be aware of - I wasn't until I recently discovered it in the documentation by accident :
TryCatch ex As Exception When [Expression]
End TryI recently needed this for a generic function which I was calling both synchronously and asynchronously (separate thread). I wanted this function to handle the exception by displaying a dialog box in case it was executed asynchronously only. So I just added a parameter to that function called 'handleException' and used it in the Catch...When statement.
Elegant!
