C
C#2y ago
Cinthia

❔ Best loading progress WPF

Hello guys, I need to implement a progress bar using IProgress interface, The problem is that I did something like this: private async task LoadData(IProgress<int> progress) {
var connection = await networkService.CheckConnectionAsync(); if(!connection.IsSuccess) { wait LoadDataBaseCountries(); progress.Report(100); } other { wait dataService.DeleteData(); progress.Report(33); wait LoadApiCountries(); progress.Report(66); wait dataService.SaveData(Country); progress.Report(100); } LoadComboBoxData(); } and the bar loads very quickly, but what takes longer to complete is the API, and I don't know how to implement slower loading on the bar
8 Replies
jcotton42
jcotton422y ago
do you have actual percentage information available to you, or are you just guessing?
Cinthia
CinthiaOP2y ago
I am just guessing I read some documentation, and usually they take the values in a List Loop, but I dont understand how to do that
jcotton42
jcotton422y ago
then an indeterminate progress bar, ring, or throbber, combined with some descriptive captions, is a much better approach
Cinthia
CinthiaOP2y ago
because my list only is created after the api request is finish thanks I will try to implement a ring
JakenVeina
JakenVeina2y ago
yeah, from a user's point of view, an indeterminate progress bar is annoying but it's less annoying than a progress bar that's just not accurate what you should do, if at all possible, is restructure to get yourself a definite known progress I.E. pre-query to get a count value or just embed one in the data you're retrieving/parsing and embed it at the front
Cinthia
CinthiaOP2y ago
thank you, i was able to do work as I want today using BackgroundWorker
jcotton42
jcotton422y ago
Wait what Weren't you already using Task?
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity. Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server