how to detect WCF service shutdown or disconnect from client?

I'm building a WCF service,after a client connects to this service,when the service disconnect, the client doesn't notice that, and it doesn't fire any action, i would like to close client form whenever the connection lost,so how would i detect WCF service disconnect or shutdown from client side.


A simple approach is the client will call a simple method in service called IsAlive() just returns true as described in this thread.

There is another way you could achieve this using the new Discovery/Announcement features that comes with WCF 4. Though I haven't tried but this feature helps you to make the service notify the client if it gets into offline/shutdown.

Here is an example post.

You can google "WCF announement service" and you'll get some good reference materials.

You should probably just set up a timer that will continually ping the server, and if the fails, fire an event that the service is no longer available.

This answer also has some good suggestions.

WCF - have client check for service availability

Need Your Help

How to have a computer flash a light

usb monitoring status health-monitoring

I'd like to have an application monitor written in C# monitoring a set of Forex trading positions. It would be connected via USB to a real set of "traffic lights" sat on a desk which it would use to

How do I print the full value of a long string in gdb?

c++ c string debugging gdb

I want to print the full length of a C-string in GDB. By default it's being abbreviated, how do I force GDB to print the whole string?