public void OnLoadAsyncCompleted(object sender, OpenReadCompletedEventArgs e) { ContentLoadAsyncEventArgs args = new ContentLoadAsyncEventArgs(); if (null == e.Error) { try { args.m_data = XElement.Load(e.Result); } catch (Exception /*ex*/) {} } else { if (e.Error.Message == "WebException") { LoadAsync(m_context); return; } else { args.m_error = e.Error; } } if (this.LoadCompleted != null) { this.LoadCompleted(this, args); } }
public void LoadAsync(LoadContext context) { m_context = context; if (NetworkInterface.GetIsNetworkAvailable()) { if (m_context != null && m_context.Url != "") { Uri serviceUri = new Uri(m_context.Url); m_downloader.Headers[HttpRequestHeader.Referer] = "http://lab3d.ru"; m_downloader.OpenReadAsync(serviceUri); } else { ContentLoadAsyncEventArgs args = new ContentLoadAsyncEventArgs(); args.m_error = new Exception("Url is invalid!"); if (this.LoadCompleted != null) { this.LoadCompleted(this, args); } } } else { ContentLoadAsyncEventArgs args = new ContentLoadAsyncEventArgs(); args.m_error = new Exception("No network available"); if (this.LoadCompleted != null) { this.LoadCompleted(this, args); } } }