THRIFT-2032 C# client leaks sockets/handles
Patch: Jens Geyer
diff --git a/tutorial/csharp/CsharpClient/CsharpClient.cs b/tutorial/csharp/CsharpClient/CsharpClient.cs
index 8ce1085..113a472 100644
--- a/tutorial/csharp/CsharpClient/CsharpClient.cs
+++ b/tutorial/csharp/CsharpClient/CsharpClient.cs
@@ -37,45 +37,50 @@
Calculator.Client client = new Calculator.Client(protocol);
transport.Open();
-
- client.ping();
- Console.WriteLine("ping()");
-
- int sum = client.add(1, 1);
- Console.WriteLine("1+1={0}", sum);
-
- Work work = new Work();
-
- work.Op = Operation.DIVIDE;
- work.Num1 = 1;
- work.Num2 = 0;
try
{
- int quotient = client.calculate(1, work);
- Console.WriteLine("Whoa we can divide by 0");
- }
- catch (InvalidOperation io)
- {
- Console.WriteLine("Invalid operation: " + io.Why);
- }
+ client.ping();
+ Console.WriteLine("ping()");
- work.Op = Operation.SUBTRACT;
- work.Num1 = 15;
- work.Num2 = 10;
- try
- {
- int diff = client.calculate(1, work);
- Console.WriteLine("15-10={0}", diff);
- }
- catch (InvalidOperation io)
- {
- Console.WriteLine("Invalid operation: " + io.Why);
- }
+ int sum = client.add(1, 1);
+ Console.WriteLine("1+1={0}", sum);
- SharedStruct log = client.getStruct(1);
- Console.WriteLine("Check log: {0}", log.Value);
+ Work work = new Work();
- transport.Close();
+ work.Op = Operation.DIVIDE;
+ work.Num1 = 1;
+ work.Num2 = 0;
+ try
+ {
+ int quotient = client.calculate(1, work);
+ Console.WriteLine("Whoa we can divide by 0");
+ }
+ catch (InvalidOperation io)
+ {
+ Console.WriteLine("Invalid operation: " + io.Why);
+ }
+
+ work.Op = Operation.SUBTRACT;
+ work.Num1 = 15;
+ work.Num2 = 10;
+ try
+ {
+ int diff = client.calculate(1, work);
+ Console.WriteLine("15-10={0}", diff);
+ }
+ catch (InvalidOperation io)
+ {
+ Console.WriteLine("Invalid operation: " + io.Why);
+ }
+
+ SharedStruct log = client.getStruct(1);
+ Console.WriteLine("Check log: {0}", log.Value);
+
+ }
+ finally
+ {
+ transport.Close();
+ }
}
catch (TApplicationException x)
{