In Silverlight 3 you are able to check if an internet connection is present. You can also detect network changes.
See also:
Silverlight 3 as a Desktop Application (Out-of-Browser Applications)
Network availability checking:
if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) |
{ |
this.InitTasks(); |
} |
Network change detection:
NetworkChange.NetworkAddressChanged += new |
NetworkAddressChangedEventHandler(NetworkChangedCallback); |
private void NetworkChangedCallback(object sender, EventArgs e) |
{ |
if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) |
{ |
this.InitTasks(); |
} |
} |
Demo
As an example I created the following demo:
This is a simple tasks list. You can add or delete tasks. The tasks are saved on the server and the application is using WCF Service to connect to the server. Nothing special. But if you save the application for offline use you can use it even if you don't have internet connection. I'm using the
isolated storage to keep copy of the data on the client and the application is working with the local copy when there is no connection. It synchronizes automatically whenever the connection comes back.
Download Source