I am trying to load all the users in our active directory and display them in a ListBox. However if I do this like normal I freeze the UI thread for a long time. So is there anyway I can use a task to fill this collection up on a background thread while still getting the listbox to update as I insert new names?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
As you cannot load all the data in a separate thread (or task, whatever) and then fill the ObservableCollection, you can pass the current Dispatcher to the operation and use its InvokeAsync method to add the elements one by one to the Observable collection in the UI thread. Something like this:
I would do that in batches, though, depending on the number of elements.