HttpListener implements IDisposable but there is not Dispose() method, why and how can I dispose it?


3 Replies
you could cast it to IDisposable first and then dispose it, some classes hide their implementation of Dispose for one reason or another
IE
(_listener as IDisposable).Dispose()
or ((IDisposable) _listener).Dispose()
Any particular reason you're trying to dispose it manually instead of a
using
block/statement?I am using 1 HttpListener for all incoming connection, so I am trying to do same things like HttpClient
re-using I mean
any way I found the way to do: this class contains Close() method which is pretty-much an alias for Dispose()