There is a team that, according to a selected book, finds students who have been given a book.

if (SelectItem is Book book) FormSource = from st in students from fm in forms where fm.IDBook == book.ID && fm.IDForm == st.ID select new { st.ID, st.FullName, st.Group, fm.DateOfIssue }; 

SelectItem is the selected item in the datagrid books.

students and forms are an ObservableCollection preloaded from the database.

 _library.Students.Load(); _library.Forms.Load(); 

FormSource is an ItemSource DataGrid on which the students to whom this book is issued are displayed.

Since I will have many students and forms for them, I need to perform this task asynchronously. It is desirable that the FormSource updated gradually. And still need to somehow cancel the running task when you re-execute the command.

The complete project on github. Criticism is welcome.

  • one
    нужно данную задачу выполнять асинхронно What does this mean in your understanding? - tym32167
  • That it was executed not in the UI stream, that is, did not block the interface - flash1371
  • so wrap the code you need in Task.Run(()=>{....}) and it will be executed on the thread pool - tym32167
  • And what about a canceled task when launching a new and gradual update of the FormSource? - flash1371
  • use CancellationToken to cancel the operation - tym32167

0