public static void GetAboutXml(string uri, IsConnectedCallback callback) { Initialize(); Thread t = new Thread(() => { try { WebRequest request = WebRequest.Create(uri); HttpWebResponse response = request.GetResponse() as HttpWebResponse; callback(response != null && (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Accepted)); } catch (Exception e) { Log.Warning("Failed to find About.xml in host: [" + e.GetType().Name + "]\n" + e.GetType() + " " + e.Message); callback(false); } }); t.IsBackground = true; t.Start(); }
public static void CheckForInternetConnectionAsync(IsConnectedCallback callback) { Initialize(); Thread t = new Thread(() => { try { WebRequest request = WebRequest.Create("http://www.google.com"); HttpWebResponse response = request.GetResponse() as HttpWebResponse; callback(response != null && (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Accepted)); } catch (Exception e) { Log.Warning("ModSyncRW: Error connecting to internet: " + e.GetType().Name + " " + e.Message); callback(false); } }); t.IsBackground = true; t.Start(); }