IEventHookServiceRaiseEvent(Guid, ActionDelegate) Method |
Raises an application event, but gives the caller control over how each subscriber is invoked.
Namespace: Dundas.BIAssembly: Dundas.BI.Core (in Dundas.BI.Core.dll) Version: 2.0.0.0 (26.2.0.1000)
Syntaxvoid RaiseEvent(
Guid eventHookId,
Action<Delegate> invokeSubscriberAction
)
Sub RaiseEvent (
eventHookId As Guid,
invokeSubscriberAction As Action(Of Delegate)
)
void RaiseEvent(
Guid eventHookId,
Action<Delegate^>^ invokeSubscriberAction
)
abstract RaiseEvent :
eventHookId : Guid *
invokeSubscriberAction : Action<Delegate> -> unit Parameters
- eventHookId Guid
- The ID of the event hook.
- invokeSubscriberAction ActionDelegate
- The delegate to invoke a subscriber. See remarks.
Exceptions
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.
Example
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);
}
}
);
See Also