/// <summary> /// Import CSV de données. Attention le DTO en question doit implémenter l'interface ISerializableCSV /// </summary> /// <param name="obj"></param> private void ImportCSVDelegate(object obj) { List <ISerializableCSV> list; if (IsLoading == Visibility.Visible) { ShowMessageBox.Show(TYPE_WINDOW_BOX.AVERTISSEMENT, messLoading, ""); } else { ThreadPool.QueueUserWorkItem(async => { var dispatcher = Application.Current.Dispatcher; dispatcher.Invoke(() => { IsLoading = Visibility.Visible; }); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "CSV files (*.csv)|*.csv"; openFileDialog.CheckFileExists = true; openFileDialog.CheckPathExists = true; openFileDialog.Multiselect = false; openFileDialog.Title = String.Format("{0}", "Import CSV File"); if (openFileDialog.ShowDialog() == true) { ReadAndWriteCSV readAndWriteCSV = new ReadAndWriteCSV(openFileDialog.FileName, ";"); ReadAndWriteCSV.encoding = System.Text.Encoding.Default; Type type = BLL.CreateElement().GetType(); list = readAndWriteCSV.ReadCSV(type); ListSource = new ObservableCollection <IDTO>(ListSource.Concat <ISerializableCSV>(list).Cast <IDTO>()); } dispatcher.Invoke(() => { IsLoading = Visibility.Hidden; }); }); } }