private async void loopRefreshInterface() { while (true) { if (save_tb2 != null && dl_text_val != null && isTextRefresh) { save_tb2.Text = dl_text_val; isTextRefresh = false; } if (pg1 != null && pg2 != null) { pg1.Value = pg1Val; pg2.Value = pg2Val; } if (isStart == false) { ButtonStart.IsEnabled = true; Buttonstop.IsEnabled = false; } if (isSagasRefresh) { listSagas.Items.Clear(); printMangas.Clear(); foreach (KeyValuePair <String, String> pair in allMangas) { if (SearchBox.Text.ToString() == null || SearchBox.Text.ToString() == "" || pair.Key.ToLower().IndexOf(SearchBox.Text.ToString().ToLower()) != -1) { printMangas.Add(pair); ListBoxItem itm = new ListBoxItem(); itm.Content = pair.Key; listSagas.Items.Add(itm); } } isSagasRefresh = false; } if (isOneSagaRefresh) { gridSagas.Visibility = Visibility.Hidden; gridOneSaga.Visibility = Visibility.Visible; if (allBooks.Count > 0 && allBooks[0].getIndex() == -1) { TitleSaga.Text = currentSaga.getName() + " - Attention, la série est licensié !"; buttonDownloadSaga.IsEnabled = false; } else { buttonDownloadSaga.IsEnabled = true; TitleSaga.Text = currentSaga.getName(); } DetailsSaga.Text = currentSaga.getAuteur() + " - " + currentSaga.getAnnée(); ResumeSaga.Text = currentSaga.getResumé(); if (currentSaga.getImgLink() != null) { BitmapImage bi3 = new BitmapImage(); bi3.BeginInit(); bi3.UriSource = new Uri(currentSaga.getImgLink(), UriKind.RelativeOrAbsolute); bi3.CacheOption = BitmapCacheOption.OnLoad; bi3.EndInit(); CoverSaga.Source = bi3; } else { CoverSaga.Source = null; } listBook.Items.Clear(); foreach (Chapters c in allBooks) { if (c.getIndex() != -1) { String tmp_content = ""; if (c.isChapter() == true) { if (c.getTitle() == null) { tmp_content = "Chapitre " + c.getNumber() + " "; } else { tmp_content = "Chapitre " + c.getNumber() + " : " + c.getTitle(); } } else { if (c.getTome().getTitle() != null) { tmp_content = "Tome " + c.getNumber() + " : " + c.getTome().getTitle(); } else { tmp_content = "Tome " + c.getNumber() + " "; } } if (c.date == null) { listBook.Items.Add(tmp_content); } else { listBook.Items.Add(c.date + " - " + tmp_content); } } } isOneSagaRefresh = false; } if (isDownloadRefresh) { int selectId = listBoxDownload.SelectedIndex; int id = 0; listBoxDownload.Items.Clear(); foreach (Download dl in listDownload) { addDownloadListBox(dl, id); id++; } if (selectId >= 0 && listBoxDownload.Items.Count > 0 && selectId < listBoxDownload.Items.Count) { listBoxDownload.SelectedItem = listBoxDownload.Items.GetItemAt(selectId); listBoxDownload.ScrollIntoView(listBoxDownload.SelectedItem); } isDownloadRefresh = false; } await Task.Delay(10); } }