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?
This is actually pretty easy, though the solution doesn’t really have anything to do with WCF. Create a wrapper
Streamsubclass that you pass the actual source Stream into. In the variousReadoverrides, 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.