IEventHookServiceRaiseEvent Method (Guid, ActionDelegate)

Raises an application event, but gives the caller control over how each subscriber is invoked.

Namespace:  Dundas.BI
Assembly:  Dundas.BI.Core (in Dundas.BI.Core.dll) Version: 2.0.0.0 (24.3.0.1000)
Syntax
void RaiseEvent(
	Guid eventHookId,
	Action<Delegate> invokeSubscriberAction
)

Parameters

eventHookId
Type: SystemGuid
The ID of the event hook.
invokeSubscriberAction
Type: SystemActionDelegate
The delegate to invoke a subscriber. See remarks.
Exceptions
ExceptionCondition
ArgumentExceptioneventHookId was Empty.
ArgumentNullExceptioninvokeSubscriberAction was .
Remarks
For each subscriber to the event, invokeSubscriberAction will be invoked. The parameter to invokeSubscriberAction is the delegate representing the subscriber, which invokeSubscriberAction is responsible for invoking with the proper arguments.
Examples

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.

C#
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);
    }
  }
);
See Also