Exemplo n.º 1
0
        private void buttonGetBuffer_Click(object sender, EventArgs e)
        {
            String guidStr = listBoxClients.SelectedItem.ToString();
            Guid   guid    = (from c in m_registeredClients
                              where c.ToString().Equals(guidStr)
                              select c).FirstOrDefault();

            if (guid == null)
            {
                return;
            }

            using (ChannelFactory <IMainToChildMessages> factory = new ChannelFactory <IMainToChildMessages>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/Child_" + guidStr)))
            {
                IMainToChildMessages channel = factory.CreateChannel();
                try
                {
                    String str = channel.GetStringFromBuffer();
                    textBoxBuffer.Text = str;
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    CloseChannel((ICommunicationObject)channel);
                }
            }
        }
Exemplo n.º 2
0
        private void buttonGet_Click(object sender, EventArgs e)
        {
            String guidStr = listBoxClients.SelectedItem.ToString();
            Guid   guid    = (from c in m_registeredClients
                              where c.ToString().Equals(guidStr)
                              select c).FirstOrDefault();

            if (guid == null)
            {
                return;
            }

            using (ChannelFactory <IMainToChildMessages> factory = new ChannelFactory <IMainToChildMessages>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/Child_" + guidStr)))
            {
                IMainToChildMessages channel = factory.CreateChannel();
                try
                {
                    String start = textBoxStartIndex.Text;
                    int    nStart;
                    Int32.TryParse(start, out nStart);
                    String length = textBoxLength.Text;
                    int    nLength;
                    Int32.TryParse(length, out nLength);
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    CloseChannel((ICommunicationObject)channel);
                }
            }
        }
Exemplo n.º 3
0
 private void RemoveChild(string guidStr)
 {
     using (ChannelFactory <IMainToChildMessages> factory = new ChannelFactory <IMainToChildMessages>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/Child_" + guidStr)))
     {
         IMainToChildMessages channel = factory.CreateChannel();
         try
         {
             channel.TerminateProcess();
         }
         catch (Exception ex)
         {
         }
         finally
         {
             CloseChannel((ICommunicationObject)channel);
         }
     }
 }