private void LoadAssemblies() { _assemblies.Clear(); _types.Clear(); _allTypes.Clear(); _legend.Clear(); _referencedAssemblies.Clear(); _currentGraph = null; ReferencedAssemblies?.Clear(); AssemblyTypesSource?.Clear(); Assemblies.SelectedItem = null; Types.SelectedItem = null; Types.IsEnabled = false; Dispatcher.Invoke(() => { Loading.Visibility = Visibility.Visible; MainGrid.IsEnabled = false; }); var files = Directory.GetFiles(App.AssembliesPath, "*.dll"); Task.Factory.StartNew(() => { Parallel.ForEach(files, file => { try { Assembly assembly; using (Stream stream = File.OpenRead(file)) { byte[] rawAssembly = new byte[stream.Length]; stream.Read(rawAssembly, 0, (int)stream.Length); assembly = Assembly.Load(rawAssembly); } var types = GetLoadableTypes(assembly).Where(x => _nameCheck.IsMatch(x.Name)).OrderBy(x => x.Name).ToList(); _allTypes.AddRange(types.Except(_allTypes)); _assemblies.Add(assembly.GetName().Name, assembly); _types.Add(assembly.GetName().Name, types.OrderBy(x => x.Name).Select(x => new ComboBoxItem { Content = x.Name, Tag = x })); } catch (Exception) { } }); _assemblies = _assemblies.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); Dispatcher.Invoke(() => { Assemblies.IsEnabled = true; Zoom.Visibility = Visibility.Visible; OnPropertyChanged(nameof(AllAssemblies)); OnPropertyChanged(nameof(AllTypes)); OnPropertyChanged(nameof(GraphItem)); OnPropertyChanged(nameof(TotalVertices)); }); Dispatcher.Invoke(() => { Loading.Visibility = Visibility.Collapsed; MainGrid.IsEnabled = true; }); }); }