locked
Inter process communication RRS feed

  • Question

  • Hi all,

    Does Silverlight supports any interprocess communication mechanism? If so, which one and where I could find more information about it?

     Thanks in advance,

     Andre

    Friday, May 15, 2009 4:11 PM

Answers

  • You must be sending the message from a background thread.  I don't think you can do that.  Do something like:

    control.Dispatcher.BeginInvoke(() => { sender.SendAsync(message_); }

    where control is whatever UI control you can get a hold of.

    Wednesday, May 20, 2009 12:14 AM

All replies

  • The closest thing you have to IPC on Silverlight is LocalMessage, available in SL3 beta. You can send and receive messages to other SL applications running on the same machine, and the SL applications can be on different browsers, same browser, online, or offline. Otherwise, the answer is no (pretty obvious from the sandboxing perspective).
    Friday, May 15, 2009 5:26 PM
  • watch this post to know LocalConnections in Silverlight 3.0

    http://www.silverlightplayground.org/post/2009/03/18/Silverlight3-Local-Connections.aspx

    if you are on SL2 you can use HtmlBridge to tunnel calls from an instance to another.

    if you mean IPC like communications with other processes on the client machine... 
    ...it is not possible.

    HTH

    Friday, May 15, 2009 6:32 PM
  • The only option you could do, if you have install access to the machine, is to host a WCF service in the other application and the calling it from the silverlight app using localhost as the address.

     While this will work, it is limited to machines that you can host the service on.

     If this answers the question, please mark as the answer.

    chad

    Friday, May 15, 2009 11:45 PM
  • Thanks for the info Andrea. It was what I was looking for.

    I have coded these both classes to communicate between 2 different thread, but I at the marked point, I'm getting an UnauthorizedAccessException (invalid cross-thread access).

    Any ideas what I should look into to fix it?

     Thanks in Advance,

     Andre

     

    namespace SilverX.src
    {
        public delegate void OnMessageReceivedCallback(object sender, MessageReceivedEventArgs e);
    
        public class CommReceiver : Communicator
        {
            private LocalMessageReceiver receiver;
    
            public CommReceiver(string quereName_, OnMessageReceivedCallback onMessageReceivedCallback)
            {
                receiver = new LocalMessageReceiver(quereName_);
    
                receiver.MessageReceived += new System.EventHandler(onMessageReceivedCallback);
    
                receiver.Listen();
            }
        }
    }
    
    namespace SilverX.src
    {
        public class CommTransmitter : Communicator
        {
            private LocalMessageSender sender;
    
            public CommTransmitter(string queueName_)
            {
                sender = new LocalMessageSender(queueName_);
            }
    
            public void Send(string message_)
            {
                sender.SendAsync(message_); // <- Point where exception happens
            }
        }
    }
    
      
    Tuesday, May 19, 2009 8:04 PM
  • You must be sending the message from a background thread.  I don't think you can do that.  Do something like:

    control.Dispatcher.BeginInvoke(() => { sender.SendAsync(message_); }

    where control is whatever UI control you can get a hold of.

    Wednesday, May 20, 2009 12:14 AM
  • are you communicating between two threads in the same plugin instance?

    if this is true why not use shared memory, locks and events?

    HTH

    Wednesday, May 20, 2009 3:16 AM