IEventHookServiceRaiseEvent Method (Guid, ActionDelegate) |
Namespace: Dundas.BI
Exception | Condition |
---|---|
ArgumentException | eventHookId was Empty. |
ArgumentNullException | invokeSubscriberAction was . |
This example shows how this RaiseEvent overload can be used to put a try/catch around all subscribers to an event. Raising the event in this manner means that all subscribers will be invoked, even if one of them throws an exception.
object sender = this; EventArgs eventArgs = EventArgs.Empty; Engine.Current.GetService<IEventHookService>.RaiseEvent( myEventHookId, (Delegate eventSubscriber) => { try { eventSubscriber.DynamicInvoke(sender, eventArgs); } catch (Exception ex) { string subscriberName = eventSubscriber.Method.DeclaringType.FullName + "." + eventSubscriber.Method.Name; string logMsg = "Error invoking event subscriber " + subscriberName + ". Details: " + ex.ToString(); Engine.Current.GetService<ILoggingService>().LogError("MyLogChannel", 0, logMsg); } } );