Microsoft.Silverlight.Testing.Harness.GlobalExceptionHandler.ChangeExceptionBubbling C# (CSharp) Метод

ChangeExceptionBubbling() публичный статический Метод

Mark the Handled property in the event args as True to stop any event bubbling.
public static ChangeExceptionBubbling ( EventArgs e, bool exceptionHandled ) : void
e System.EventArgs Event arguments.
exceptionHandled bool /// Value indicating whether the Exception should be marked as handled. ///
Результат void
        public static void ChangeExceptionBubbling(EventArgs e, bool exceptionHandled)
        {
            #if SILVERLIGHT
            ApplicationUnhandledExceptionEventArgs args = e as ApplicationUnhandledExceptionEventArgs;
            if (args != null)
            {
                args.Handled = exceptionHandled;
            }
            #endif
        }

Usage Example

 /// <summary>
 /// Listener event for any unhandled exceptions.
 /// </summary>
 /// <param name="sender">Sender object instance.</param>
 /// <param name="e">Event arguments.</param>
 private void GlobalUnhandledExceptionListener(object sender, EventArgs e)
 {
     if (DispatcherStack.CurrentCompositeWorkItem is CompositeWorkItem)
     {
         CompositeWorkItem cd        = (CompositeWorkItem)DispatcherStack.CurrentCompositeWorkItem;
         Exception         exception = GlobalExceptionHandler.GetExceptionObject(e);
         cd.WorkItemException(exception);
         GlobalExceptionHandler.ChangeExceptionBubbling(e, /* handled */ true);
     }
     else
     {
         GlobalExceptionHandler.ChangeExceptionBubbling(e, /* handled */ false);
     }
 }