Export (0) Print
Expand All

LocalMessageReceiver Class

Silverlight

Represents the receiving end of a local messaging channel between two Silverlight-based applications.

System.Object
  System.Windows.Messaging.LocalMessageReceiver

Namespace:  System.Windows.Messaging
Assembly:  System.Windows (in System.Windows.dll)

'Declaration
Public NotInheritable Class LocalMessageReceiver _
	Implements IDisposable

The LocalMessageReceiver type exposes the following members.

  NameDescription
Public methodLocalMessageReceiver(String)Initializes a new instance of the LocalMessageReceiver class and configures it with the specified name.
Public methodLocalMessageReceiver(String, ReceiverNameScope, IEnumerable(Of String))Initializes a new instance of the LocalMessageReceiver class and configures it with the specified name, namescope requirement, and allowed sender domains.
Top

  NameDescription
Public propertyAllowedSenderDomainsGets the domains that the receiver can receive messages from.
Public propertyDisableSenderTrustCheckGets or sets a value that indicates whether the receiver can receive messages from a sender with a different Protected Mode setting.
Public propertyNameScopeGets a value that indicates whether the ReceiverName is scoped to the global namescope or to the receiver's specific domain.
Public propertyReceiverNameGets the name of the receiver.
Top

  NameDescription
Public methodDisposeStops the receiver from receiving messages and releases all resources used by the receiver.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodListenStarts listening for messages from a LocalMessageSender.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public eventMessageReceivedOccurs when a message is received from a LocalMessageSender.
Top

  NameDescription
Public fieldStatic memberAnyDomainA value that represents any domain.
Top

A LocalMessageReceiver object can receive messages from a LocalMessageSender object in a different Silverlight-based application running on the same computer. For information about using these classes, see Communication Between Local Silverlight-Based Applications.

The following code example demonstrates how to use this class. This example is part of a larger example available in How to: Implement Communication Between Local Silverlight-Based Applications.


Imports System
Imports System.Windows.Controls
Imports System.Windows.Messaging

Partial Public Class Receiver
    Inherits UserControl

    Public Sub New()

        InitializeComponent()

        Dim messageReceiver As New LocalMessageReceiver("receiver", _
            ReceiverNameScope.Global, LocalMessageReceiver.AnyDomain)
        AddHandler messageReceiver.MessageReceived, _
            AddressOf messageReceiver_MessageReceived

        Try

            messageReceiver.Listen()

        Catch ex As ListenFailedException

            output.Text = "Cannot receive messages." & Environment.NewLine & _
                "There is already a receiver with the name 'receiver'."

        End Try

    End Sub

    Private Sub messageReceiver_MessageReceived( _
        ByVal sender As Object, ByVal e As MessageReceivedEventArgs)

        e.Response = "response to " & e.Message
        output.Text = _
            "Message: " & e.Message & Environment.NewLine & _
            "NameScope: " & e.NameScope.ToString() & Environment.NewLine & _
            "ReceiverName: " & e.ReceiverName & Environment.NewLine & _
            "SenderDomain: " & e.SenderDomain & Environment.NewLine & _
            "Response: " & e.Response

    End Sub

End Class


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft