Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 15th, 2012  |  syntax: None  |  size: 0.88 KB  |  hits: 16  |  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. Process not timing out properly
  2. public Tracker Discover(Uri hostUri, string organizationTrackerId)
  3.     {
  4.         var binding = new NetTcpBinding();
  5.         binding.ReceiveTimeout = TimeSpan.FromSeconds(2);
  6.         binding.SendTimeout = TimeSpan.FromSeconds(2);
  7.         binding.OpenTimeout = TimeSpan.FromSeconds(2);
  8.         var endpointAddress = new EndpointAddress(hostUri);
  9.         using (var factory = new ChannelFactory<ITrackerService>(binding, endpointAddress))
  10.         {
  11.             try
  12.             {
  13.                 factory.Open(TimeSpan.FromSeconds(2));
  14.                 var channel = factory.CreateChannel();
  15.                 Tracker tracker = channel.Discover(organizationTrackerId);
  16.                 factory.Close();
  17.                 return tracker;
  18.             }
  19.             catch (Exception)
  20.             {
  21.                 factory.Abort();
  22.             }
  23.         }
  24.         return null;
  25.     }