I am taking the Intro to.NET Web Services course, and one of the things we are currently learning is the IDisposable interface. As a relatively simple example, I created a service (server / client) with an operation MyMethod(). The method simply prints the trace statement when it is called. I also implemented IDisposable on my server by implementing the method Dispose(), again, a simple WriteLine trace in the Server version.
In my client, I create two proxies with ChannelFactory. In proxy1, I invoke the operation MyMethod()3 times, then I have a couple of lines of code to delete proxy1:
var castedProxy = (IDisposable)proxy1;
castedProxy.Dispose();
In proxy2, I call the operation again MyMethod()3 times, except that I do not start and do not call Dispose(). When I start the server / client, I get the same traces 6 times:
Server tracking + current tag identifier
MyMethod () Trace + CurrentThread ID
Dispose () Trace + CurrentThread ID
My question is this: why does part of the trace Dispose()happen every time, although I use only the first three tracks? I assume this is due to the fact that when using BasicHttpBinding there is no session control as such, so old resources still exist, printing old Dispose () calls.
Thanks in advance for any information you can provide! :)
source
share