MessageHandler<TRecipient,TMessage> Delegate

Definition

A delegate used to represent actions to invoke when a message is received. The recipient is given as an input argument to allow message registrations to avoid creating closures: if an instance method on a recipient needs to be invoked it is possible to just cast the recipient to the right type and then access the local method from that instance.

public delegate void MessageHandler<in TRecipient,in TMessage>(TRecipient recipient, TMessage message) where TRecipient : class where TMessage : class;
type MessageHandler<'Recipient, 'Message (requires 'Recipient : null and 'Message : null)> = delegate of 'Recipient * 'Message -> unit
Public Delegate Sub MessageHandler(Of In TRecipient, In TMessage)(recipient As TRecipient, message As TMessage)

Type Parameters

TRecipient

The type of recipient for the message.

This type parameter is contravariant. That is, you can use either the type you specified or any type that is less derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
TMessage

The type of message to receive.

This type parameter is contravariant. That is, you can use either the type you specified or any type that is less derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.

Parameters

recipient
TRecipient

The recipient that is receiving the message.

message
TMessage

The message being received.

Applies to