private static void RunCallBack(ConnectedCallbackDelegate connectedToInternetCallback)
 {
     while (_myThread.IsAlive)
     {
         try
         {
             if (!IsInternetConnected)
             {
                 _disconnectCount++;
             }
             if (IsInternetConnected && (_disconnectCount > 10) &&
                 (DateTime.Now.Subtract(_notificationTime).Minutes > 10) &&
                 (_notificationCount < 5))
             {
                 Logger.LogError("Your Internet connection is unstable. If problem continues please contact your internet provider.", true);
                 _disconnectCount  = 0;
                 _notificationTime = DateTime.Now;
                 _notificationCount++;
             }
             connectedToInternetCallback(IsInternetConnected);
         }
         catch (Exception ex)
         {
             //Logger.LogError(ex);
         }
     }
 }
 private static void RunCallBack(ConnectedCallbackDelegate connectedToInternetCallback)
 {
     while (_myThread.IsAlive)
     {
         try
         {
             if (!IsInternetConnected)
             {
                 _disconnectCount++;
             }
             if (IsInternetConnected && (_disconnectCount > 10) &&
                 (DateTime.Now.Subtract(_notificationTime).Minutes > 10) &&
                 (_notificationCount < 5))
             {
                 string      statusMsg   = "";
                 Distributor _superAdmin = MasterData.Distributors.Data.Find(i => i.IsSuperAdmin);
                 EmailHelper.SendErrorMail("Your Internet connection is unstable. If problem continues please contact your internet provider.", new string[] { User.EmailId }, new string[] { _superAdmin.Dist_Email }, new string[] { });
                 SmsHelper.NotifyDitributor("Your Internet connection is unstable. If problem continues please contact your internet provider.", out statusMsg);
                 _disconnectCount  = 0;
                 _notificationTime = DateTime.Now;
                 _notificationCount++;
             }
             connectedToInternetCallback(IsInternetConnected);
         }
         catch (Exception ex)
         {
             //Logger.LogError(ex);
         }
     }
 }
 public static void CheckForInternet(ConnectedCallbackDelegate connectedToInternetCallback)
 {
     _myThread = new Thread(() => RunCallBack(connectedToInternetCallback));
     _myThread.Start();
 }