Example #1
0
        private static void logException(Delegate eventHandler, Exception ex)
        {
            string delegateSignature = DelegateExtensions.DelegateSignature(eventHandler);

            DebugLog("Dynamic Invoke Error in " + delegateSignature);
            DebugLog(ex.ToString());
        }
Example #2
0
        private object delegateEvent(Delegate eventHandler, object[] args)
        {
            string delegateSignature = DelegateExtensions.DelegateSignature(eventHandler);

            DebugLog(String.Format("SynchronizationContext's target thread; EventHandler={0}; args={1}", delegateSignature, args));
            if (SwallowExceptionsInEvents)
            {
                return(fireEventsNoThrow(eventHandler, args));
            }
            else
            {
                /// http://msdn2.microsoft.com/en-us/library/system.delegate(VS.80).aspx
                /// If an invoked method throws an exception, the method stops executing,
                /// the exception is passed back to the caller of the delegate,
                /// and remaining methods in the invocation list are not invoked.
                /// Catching the exception in the caller does not alter this behavior.
                try
                {
                    return(eventHandler.DynamicInvoke(args));
                }
                catch (Exception ex)
                {
                    logException(eventHandler, ex);
                }
                return(null);
            }
        }