Advertisement
m1o2

Safe Event Handling

Jan 30th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.29 KB | None | 0 0
  1. public void RaiseFooEvent(params object[] args)
  2. {
  3.     var handler = OnFooEvent;
  4.     if(null != handler)
  5.     {
  6.         foreach(var invocation in handler.GetInvocationList())
  7.         {
  8.             try
  9.             {
  10.                 invocation.DynamicInvoke(args);
  11.             }
  12.             catch(Exception ex)
  13.             {
  14.                 // Log Exception
  15.             }
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement