Show a progress bar when transmitting Entity Framework data

I have a project that uses data from the Entity Framework and presents it in WPF . I want to show a progress bar when the Entity Framework loads / saves data at presentation level.

Could you help me understand how I can do this?

+4
source share
2 answers

You can use Dispatcher Thread to achieve this; Basically you need to create a generic class that is extended in other user interface classes.

For this you can see a basic example here; more accurate example and downloadable code here .

+1
source

I found this neat example for this using the Skip / Take methods. Basically you load x the number of records in each round that you Skip in the next round, and calculate this from the sum of all the data in your table, which allows you to update the progress bar every round.

Take a look at this:

 List<MyDataTable> someData = new List<MyDataTable>(); int rowCount = dt.myDataTable.Count(); //TODO: <= display a progress bar here, and set max to rowCount... int currentRows = 0; while (currentRows < rowCount) { someData.AddRange(dt.myDataTable.Skip(currentRows).Take(10000).ToList()); currentRows = someData.Count; //TODO: <= update progress here... } 
+3
source

Source: https://habr.com/ru/post/1433288/


All Articles