A Sandcastle Documented Class Library

# IEventHookService RaiseEvent Method (Guid, Action Delegate )

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 (10.0.0.1002)
Syntax
C#
VB
C++
F#
Copy

    void 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
  Type: System
  Guid
  The ID of the event hook.
invokeSubscriberAction
  Type: System
  Action
  Delegate
  The delegate to invoke a subscriber. See remarks.

Exceptions

Exception | Condition
--- | ---
ArgumentException | eventHookId was Empty.
ArgumentNullException | invokeSubscriberAction 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#
Copy

    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

#### Reference

IEventHookService Interface
RaiseEvent Overload
Dundas.BI Namespace