LocalMessageReceiver Class Home
.NET Framework Class Library for Silverlight
LocalMessageReceiver Class

[Note: This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

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

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

'Usage

Dim instance As LocalMessageReceiver

'Declaration

Public NotInheritable Class LocalMessageReceiver _
    Implements IDisposable
Remarks

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.

Examples

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


Inheritance Hierarchy

System..::.Object
  System.Windows.Messaging..::.LocalMessageReceiver
Thread Safety

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

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

See Also

Reference

Other Resources

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View