I have a WPF application that works with a database. The number of records in the database is quite large and constantly growing. The project uses ORM (EF 6). There is a class that works directly with the database context:
public class Store : IStore {...}
In the class interface, a number of methods are defined, the code in which refers directly to the database through the EF context, respectively, the method takes quite a long time to execute, which can cause a simple user interface if I understand correctly. Consequently, it is necessary to make operations of receiving data from the database into separate streams. So, let's say, the Store
a method defined:
public ICollection<Product> GetAllProducts() {...}
If I understand correctly, I need to add its asynchronous implementation:
public async Task<ICollection<Product>> GetAllProductsAsync() { return await Task<ICollection<Product>>.Factory.StartNew(GetAllProducts) }
How to use this method correctly in the application itself in the ViewModel
. Let us say that while the data is being loaded, the StatusBar
displays the data loading progress and the DataGrid
displays the result as soon as the data is loaded?