WCF: Closing channel leaves stream open

260 views Asked by At

I get a Stream from a WCF-Service. I am using this stream to get data from it and copy it to another stream.

IServerService serverService = channelFactory.CreateChannel();
Stream serverStream = serverService.GetStream();
serverStream.CopyTo(localStream);

That works fine.

Now I have a scenario where I need to break up the process on some interrupt. I tried to call channelFactory.Close() and channelFactory.Abort() to stop the copy. But it does not work. The Server-Stream still copies data to the Local-Stream.

I would like to know why this does not work, and how I can force close the stream. (I know that I can close the Server-Stream to stop it, but I would like to close the ChannelFactory or the Channel)

Also is it possible to close the ChannelFactory so it closes all channels and streams immediately?
Thanks.

0

There are 0 answers