[Mono-devel-list] Re: [Mono-patches] r46767 - trunk/mcs/class/System.Web.Services/System.Web.Services.Protocols

Ben Maurer bmaurer at ximian.com
Thu Jun 30 13:36:20 EDT 2005


On Thu, 2005-06-30 at 09:29 -0400, Konstantin Triger  wrote:

> Modified: trunk/mcs/class/System.Web.Services/System.Web.Services.Protocols/HttpSimpleWebServiceHandler.cs
> ===================================================================
> --- trunk/mcs/class/System.Web.Services/System.Web.Services.Protocols/HttpSimpleWebServiceHandler.cs	2005-06-30 13:05:37 UTC (rev 46766)
> +++ trunk/mcs/class/System.Web.Services/System.Web.Services.Protocols/HttpSimpleWebServiceHandler.cs	2005-06-30 13:29:37 UTC (rev 46767)
> @@ -115,9 +115,16 @@
>  			try
>  			{
>  				object server = CreateServerInstance ();
> -				object[] res = method.Invoke (server, parameters);
> -				if (!method.IsVoid) return res[0];
> -				else return null;
> +				try {
> +					object[] res = method.Invoke (server, parameters);
> +					if (!method.IsVoid) return res[0];
> +					else return null;
> +				}
> +				finally {
> +					IDisposable disp = server as IDisposable;
> +					if (disp != null)
> +						disp.Dispose();
> +				}
>  			}

The cleanest way to do this is with the using statement. That
automatically does the try...finally for you.

Not only does it make the C# code clearer, it also enables a cool
optimization to make the bytecode shorter :-).

-- Ben




More information about the Mono-devel-list mailing list