//------------------------------------------------------------------------------
 //
 // Method: SerializeAndSend
 //
 //------------------------------------------------------------------------------
 /// <summary>
 /// Provides common method invocation serialization and sending functionality to public methods.
 /// </summary>
 /// <param name="inputMethodInvocation">The method invocation to serialize and send.</param>
 /// <returns>The serialized return value of the method invocation.</returns>
 private string SerializeAndSend(IMethodInvocation inputMethodInvocation)
 {
     try
     {
         string serializedMethodInvocation = serializer.Serialize(inputMethodInvocation);
         sender.Send(serializedMethodInvocation);
         return(receiver.Receive());
     }
     catch (Exception e)
     {
         throw new Exception("Failed to invoke method.", e);
     }
 }
        /// <include file='InterfaceDocumentationComments.xml' path='doc/members/member[@name="M:MethodInvocationRemoting.IMethodInvocationRemoteReceiver.Receive"]/*'/>
        public void Receive()
        {
            cancelRequest = false;

            receiveLoopThread = new Thread(delegate()
            {
                while (cancelRequest == false)
                {
                    try
                    {
                        string serializedMethodInvocation = receiver.Receive();
                        if (serializedMethodInvocation != "")
                        {
                            metricsUtilities.Begin(new RemoteMethodReceiveTime());

                            IMethodInvocation receivedMethodInvocation;

                            try
                            {
                                receivedMethodInvocation = serializer.Deserialize(serializedMethodInvocation);
                                OnMethodInvocationReceived(new MethodInvocationReceivedEventArgs(receivedMethodInvocation));
                            }
                            catch (Exception e)
                            {
                                metricsUtilities.CancelBegin(new RemoteMethodReceiveTime());
                                throw;
                            }

                            loggingUtilities.Log(this, LogLevel.Information, "Received method invocation '" + receivedMethodInvocation.Name + "'.");
                        }
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Failed to invoke method.", e);
                    }
                }
            });
            receiveLoopThread.Name = "MethodInvocationRemoting.MethodInvocationRemoteReceiver message receive worker thread.";
            receiveLoopThread.Start();
        }
Exemple #3
0
 /// <include file='InterfaceDocumentationComments.xml' path='doc/members/member[@name="M:MethodInvocationRemoting.IRemoteReceiver.Receive"]/*'/>
 public string Receive()
 {
     return(DecompressString(remoteReceiver.Receive()));
 }