Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jun 21st, 2011  |  syntax: C#  |  size: 1.35 KB  |  views: 68  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class ClientClass : ClientInterface
  2.     {
  3.         public void OnCallback(object aUpdatedObject)
  4.         {
  5.             try
  6.             {
  7.                 Form1.addTextOnInstance(aUpdatedObject.ToString());
  8.             }
  9.             catch (Exception ex)
  10.             {
  11.                 Form1.addTextOnInstance(ex.ToString());
  12.             }
  13.         }
  14.     }
  15.  
  16. /*************************************************
  17.  * I do this in my application upon startup
  18. */
  19. private void Form1_Load(object sender, EventArgs e)
  20.         {
  21.             NetNamedPipeBinding tBinding = new NetNamedPipeBinding();
  22.             tBinding.MaxReceivedMessageSize = 2000000;
  23.  
  24.            
  25.             ClientClass tClientClass = new ClientClass();
  26.             DuplexChannelFactory<RequestInterface> pipeFactory =
  27.              new DuplexChannelFactory<RequestInterface>(
  28.                 tClientClass,
  29.                 tBinding,
  30.                 new EndpointAddress(
  31.                    "net.pipe://localhost/Request"));
  32.  
  33.             try
  34.             {
  35.                 RequestInterface tInterface = pipeFactory.CreateChannel();
  36.  
  37.                 tInterface.Subscribe();
  38.                 addText("completed successfully");
  39.             }
  40.             catch (Exception aEx)
  41.             {
  42.                 addText(aEx.Message);
  43.                 addText(aEx.ToString());
  44.             }
  45.         }
clone this paste RAW Paste Data