private void MetroWindow_Unloaded(object sender, RoutedEventArgs e) { if (client != null) { client.Dispose(); client = null; } }
private FalkirkWebClient GetWebClient() { if (client == null) { client = new FalkirkWebClient(); client.DownloadStringCompleted += Client_DownloadStringCompleted; } return(client); }
private void Client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { client.Dispose(); client = null; if (!e.Cancelled && e.Error == null) { UpdateBins(e.Result); StartRefreshTimer(false); UpdateNagTimer(); } else { UpdateUi(DisplayStatus.NetworkError); StartRefreshTimer(true); } }
private void FetchBinData() { var uprn = Properties.Settings.Default.Uprn; if (string.IsNullOrEmpty(uprn)) { UpdateUi(DisplayStatus.NoLocation); } else { UpdateUi(DisplayStatus.Busy); binStatus.Clear(); refreshTimer.Stop(); var start = DateTime.Now.Date; var end = start.AddDays(90); client = new FalkirkWebClient(); client.DownloadStringCompleted += Client_DownloadStringCompleted; client.FetchCalendarDataAsync(uprn, start, end); } }