public string Get(string id) { IReqSocket client = _factory.Create(); try { return(client.SendRequest(id)); } finally { _factory.Release(client); } }
private void RequestThread(object clientFactory) { IReqSocket client = null; try { client = ((ClientFactory)clientFactory).Create(); Console.WriteLine("Client connected."); string response = client.SendRequest(string.Format("Request #{0}", Thread.CurrentThread.ManagedThreadId)); Console.WriteLine(response); Assert.AreEqual(string.Format("Reply (Request #{0})", Thread.CurrentThread.ManagedThreadId), response); } finally { if (client != null) { ((ClientFactory)clientFactory).Release(client); } } }