TEventType
TPayload
Intersoft ClientUI Documentation
Subscribe<TEventType,TPayload>(Action<TPayload>,SubscribeOptions,Predicate<TPayload>) Method
See Also  Send Feedback
Intersoft.Client.Framework Namespace > EventAggregator Class > Subscribe Method : Subscribe<TEventType,TPayload>(Action<TPayload>,SubscribeOptions,Predicate<TPayload>) Method






action
The delegate that gets executed when the event is published.
options
Specifies the options to apply to the subscription.
filter
Filter to evaluate if the subscriber should receive the event.
Subscribes a delegate to an event.

Syntax

Visual Basic (Declaration) 
Public Overloads Function Subscribe
     (Of TEventType As DelegateEventBase,
     TPayload)( _
   ByVal action As Action(Of TPayload), _
   ByVal options As SubscribeOptions, _
   ByVal filter As Predicate(Of TPayload) _
) As SubscriptionToken
Visual Basic (Usage)Copy Code
Dim instance As EventAggregator
Dim action As Action(Of TPayload)
Dim options As SubscribeOptions
Dim filter As Predicate(Of TPayload)
Dim value As SubscriptionToken
 
value = instance.Subscribe(Of TEventType, TPayload)(action, options, filter)
C# 
public SubscriptionToken Subscribe<TEventType,TPayload>( 
   Action<TPayload> action,
   SubscribeOptions options,
   Predicate<TPayload> filter
)where TEventType: DelegateEventBase
Delphi 
public function Subscribe( 
    action: Action;
    options: SubscribeOptions;
    filter: Predicate
): SubscriptionToken; 
JScript 
public function Subscribe( 
   action : Action,
   options : SubscribeOptions,
   filter : Predicate
) : SubscriptionToken;
Managed Extensions for C++ 
public: SubscriptionToken* Subscribe<TEventType,TPayload>( 
   Action<TPayload*>* action,
   SubscribeOptions options,
   Predicate<TPayload*>* filter
) where TEventType: DelegateEventBase
C++/CLI 
public:
SubscriptionToken^ Subscribegeneric<typename TEventType>
generic<typename TPayload>
( 
   Action<TPayload^>^ action,
   SubscribeOptions options,
   Predicate<TPayload^>^ filter
) where TEventType: DelegateEventBase

Parameters

action
The delegate that gets executed when the event is published.
options
Specifies the options to apply to the subscription.
filter
Filter to evaluate if the subscriber should receive the event.

Type Parameters

TEventType
TPayload

Return Value

A SubscriptionToken that uniquely identifies the added subscription.

Remarks

If options contains UseStrongReference flag, the action and filter references will be keep alive. In such case, you must explicitly call Unsubscribe for the event when disposing the subscriber in order to avoid memory leaks or unexpected behaviors.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2012 All Rights Reserved.