Reputation: 6122
I have a simple console app that calls a WCF service over net.tcp and uploads a file (using Stream
). The WCF service is self-hosted, Framework 4.0.
I am looking for a way to now add some "progress info" on the client-side. Should this be done with hand-written IASync operations, or something else altogether?
Upvotes: 0
Views: 230
Reputation: 33379
This is actually pretty easy, though the solution doesn't really have anything to do with WCF. Create a wrapper Stream
subclass that you pass the actual source Stream into. In the various Read
overrides, first delegate to the underlying Stream you're wrapping. Next, increment a custom property with the number of bytes read and either fire a custom event or maybe implement INotifyPropertyChanged on the custom Stream subclass. By doing this, as WCF reads from the wrapper Stream to get the bytes to send over the wire, your client will be able to observe the changes.
Upvotes: 2