View Single Post
 
Old 09-10-2007, 07:06 AM
shaul_ahuva shaul_ahuva is offline
Ultimate Contributor

Retired Leader
* Expert *
 
Join Date: Jul 2003
Location: Camp Hill, PA
Posts: 1,992
Default

Good points, AtmaWeapon! I have to say, I'm guilty of not ensuring my events are thread safe

I wanted to point out another issue with events and exceptions - remoting clients. If a remoting server raises an event, there is the distinct possibility (read: it will happen) that the client will disconnect without notice due to power failures, hard reboots or throwing the computer out the window. In this case, the only way to safely handle the problem is to enumerate the invocation list - in the past I've simply swallowed the exception since my server doesn't care if/when clients connect/disconnect, but I realize this won't handle all scenarios.

Ultimately, you're right about "normal" event scenarios - you should *always* wrap your code in try/catch blocks if there's the possibility of an exception being thrown.
Reply With Quote