I have a Window-Form Application connecting to a server for database updates. When application starts, I connect to the internet. On the Form I show a green Button, which shows internet connectivity on Load-Event. If there is no connectivity then it shows a red button.
public bool check()
{
    try
    {
        Ping myPing = new Ping();
        String host = "google.com";
        byte[] buffer = new byte[32];
        int timeout = 1000;
        PingOptions pingOptions = new PingOptions();
        PingReply reply = myPing.Send(host, timeout, buffer, pingOptions);
        return (reply.Status == IPStatus.Success);
    }
    catch (Exception)
    {
       return false;
    }
}
I want this button change it's color automatic, when ever it lost it's connectivity from internet or when internet come back.
How i can implement this?