Export (0) Print
Expand All

LocalMessageSender Constructor (String)

Silverlight

Initializes a new instance of the LocalMessageSender class and configures it to send messages to the receiver with the specified name.

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

public LocalMessageSender(
	string receiverName
)

Parameters

receiverName
Type: System.String
The ReceiverName property value of the LocalMessageReceiver that this sender will send messages to.

ExceptionCondition
ArgumentNullException

receiverName is null.

ArgumentException

receiverName is longer than 256 characters.

This constructor initializes the ReceiverName property to the specified value. The ReceiverDomain property remains null, which indicates that the sender can send messages only to a receiver on the same domain.

For more information, see Communication Between Local Silverlight-Based Applications.

The following code example demonstrates how to use this constructor.


// In the receiving application:
LocalMessageReceiver messageReceiver = new LocalMessageReceiver("receiver");
messageReceiver.MessageReceived += new 
    EventHandler<MessageReceivedEventArgs>(receiver_MessageReceived);
try
{
    messageReceiver.Listen();
}
catch (ListenFailedException)
{
    MessageBox.Show(
        "Cannot receive messages." + Environment.NewLine +
        "There is already a receiver with the name 'receiver'.",
        "LocalMessageReceiver", MessageBoxButton.OK);
}

// In the sending application:
LocalMessageSender messageSender = new LocalMessageSender("receiver");
messageSender.SendCompleted += new 
    EventHandler<SendCompletedEventArgs>(sender_SendCompleted);


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.

Community Additions

ADD
Show:
© 2014 Microsoft