static void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { if (e.Error == null) { InternetAvailable = true; InternetConnected?.Invoke(true); } else { // System.Windows.Forms.MessageBox.Show(e.Error.Message); } }
public bool IsConnected() { // Attempt to reconnect regularly if (!_isConnected && IsInternetConnected()) { Task.Run(async() => { if (await Connect()) { InternetConnected?.Invoke(); } }); } return(_isConnected); }