>2. What the advantage of assigning socket to the s
> local variable, and then call the Close() method
> on it?
If you mean
---
// release unmanaged resources
if (socket != null){
socket.Close ();
socket = null;
}
}
--- Instead of ---
// release unmanaged resources
Socket s = socket;
socket = null;
if (s != null)
s.Close ();
}
---
One difference is that if an exception is thrown in the s.Close, then the socket
(variable) is already set to null. This could be the reason, but I'm only guessing.
Steinar
-----Original Message-----
From: Gonzalo Paniagua Javier [mailto:[EMAIL PROTECTED]
Sent: 14. oktober 2003 08:43
To: [EMAIL PROTECTED]
Subject: Re: [Mono-list] Dispose() method in the UdpClient class
El mar, 14-10-2003 a las 08:11, Giuseppe Greco escribi�:
> 1. Isn't Socket a managed resource?
The Socket class holds a socket, that is an unmanaged resource. That's why it's better
to Close it explicitly instead of letting the GC do it.
-Gonzalo
_______________________________________________
Mono-list maillist - [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list
_______________________________________________
Mono-list maillist - [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list