Monitor network activity on a WCF Duplex client
|September 5, 2014||Posted by forumadmin under TechQns||
First of all sorry if I say something that don’t make sense, I did not create the whole software architecture so I don’t have knowledge of every details.
We use a desktop Win32 client application (C# and WPF, not ASP.NET) communicating over WCF with a DuplexClientBase and NetTcpBinding. We use an Async pattern for all service calls (call the command in non-blocking mode and use Rx to subscribe and handle the reply when it’s ready). We also have some callbacks that can trigger at any time from the server.
My question is simple, is there a way to know if there is any network activity currently going on, or a service call waiting for a reply. I just want to display some UI element (busy indicator) notifying the user that the application is currently working. I don’t really need any progress information (% complete), just a boolean would do. Callbacks aren’t that important either, just the async service calls would do.
I saw a few example online where they keep track themselves of when they send a commands and when the reply comes back. Unfortunately, that require you to implement the same code for every service calls which can be tedious when you have many. I was looking for a property directly on the DuplexClientBase class that I could watch, but it don’t seem like it exist.
I found about IClientMessageInspector that have “BeforeSendRequest” and “AfterReceiveReply” methods that could probably work, but it seems overkill. I don’t want to modify the messages, just know when one is active or not.
|Asked By – Dunge||Read Answers|