[Mono-list] Dispose() method in the UdpClient class
Giuseppe Greco
giuseppe.greco@agamura.com
Tue, 14 Oct 2003 08:11:44 +0200 (CEST)
Hi all,
I've given a look at the source code of the
UdpClient class... and the Dispose() method
looks like this:
void Dispose (bool disposing)
{
if (disposed)
return;
disposed = true;
if (disposing) {
// release managed resources
}
// release unmanaged resources
Socket s = socket;
socket = null;
if (s != null)
s.Close ();
}
Well, now I've two questions:
1. Isn't Socket a managed resource?
2. What the advantage of assigning socket to the s
local variable, and then call the Close() method
on it?
Please, understand me right! This is not a critic.
I'm implementing something similar, and since I use
to call Socket.Close() inside the "if (disposing) {}"
block, I just want to know if I'm wrong.
Thanks,
Gius_.
----------------------------------------
Giuseppe Greco
::agamura::
phone: +41 (0)91 604 67 65
mobile: +41 (0)76 390 60 32
email: giuseppe.greco@agamura.com
web: www.agamura.com
----------------------------------------